s3:vfs aio_fork children do not go away
authorChristian Ambach <christian.ambach@de.ibm.com>
Thu, 13 Jan 2011 15:04:36 +0000 (16:04 +0100)
committerVolker Lendecke <vl@samba.org>
Fri, 14 Jan 2011 15:58:15 +0000 (16:58 +0100)
on RHEL 5.5, recvmsg() does not return when it is reading
from the socket and the process on the other side closes
its connection. This left aio children around that should
have gone already and were just wasting system resources.

This patch makes the child go away by writing invalid
data to it so that the child exits.

Pair-Programmed-With: Volker Lendecke <vl@samba.org>

Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Fri Jan 14 09:57:18 CET 2011 on sn-devel-104

source3/modules/vfs_aio_fork.c

index fc5b7f19413735b0e6509259a67520ebeadecbab..0d515130eeb0517bd58ae2517fb22fe6a17d49f0 100644 (file)
@@ -422,7 +422,18 @@ static void handle_aio_completion(struct event_context *event_ctx,
 
 static int aio_child_destructor(struct aio_child *child)
 {
+       char c=0;
+
        SMB_ASSERT((child->aiocb == NULL) || child->cancelled);
+
+       DEBUG(10, ("aio_child_destructor: removing child %d on fd %d\n",
+                       child->pid, child->sockfd));
+
+       /*
+        * closing the sockfd makes the child not return from recvmsg() on RHEL
+        * 5.5 so instead force the child to exit by writing bad data to it
+        */
+       write(child->sockfd, &c, sizeof(c));
        close(child->sockfd);
        DLIST_REMOVE(child->list->children, child);
        return 0;
@@ -486,7 +497,8 @@ static NTSTATUS create_aio_child(struct smbd_server_connection *sconn,
                aio_child_loop(result->sockfd, result->map);
        }
 
-       DEBUG(10, ("Child %d created\n", result->pid));
+       DEBUG(10, ("Child %d created with sockfd %d\n",
+                       result->pid, fdpair[0]));
 
        result->sockfd = fdpair[0];
        close(fdpair[1]);