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)
committerChristian Ambach <christian.ambach@de.ibm.com>
Mon, 17 Jan 2011 13:12:05 +0000 (14:12 +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>

source3/modules/vfs_aio_fork.c

index 8ee660d7b8a6af0de16add6cd8cba6eeafccf01d..512ae436e85d171808c122acc5542f78a550bde9 100644 (file)
@@ -418,7 +418,19 @@ 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;
@@ -481,7 +493,8 @@ static NTSTATUS create_aio_child(struct aio_child_list *children,
                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]);