vfs_aio_fork
authorStefan Metzmacher <metze@samba.org>
Wed, 9 Nov 2011 07:51:16 +0000 (08:51 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 10 May 2012 16:47:06 +0000 (18:47 +0200)
source3/modules/vfs_aio_fork.c

index f3e8f7fda173422985a08ecaa40c09c9dab4f160..cae38a3044d210977d7f55c8054d6e5a50c7ea92 100644 (file)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#define SOCKET_WRAPPER_NOT_REPLACE
+
 #include "includes.h"
 #include "system/filesys.h"
 #include "system/shmem.h"
@@ -310,7 +312,7 @@ static struct aio_child_list *init_aio_children(struct vfs_handle_struct *handle
        return data;
 }
 
-static void aio_child_loop(int sockfd, struct mmap_area *map)
+static void aio_child_loop(int sockfd, struct mmap_area *map, int snum)
 {
        while (true) {
                int fd = -1;
@@ -329,8 +331,10 @@ static void aio_child_loop(int sockfd, struct mmap_area *map)
                           cmd_struct.read_cmd ? "read" : "write",
                           (int)cmd_struct.n, (int)cmd_struct.offset, fd));
 
-#ifdef ENABLE_BUILD_FARM_HACKS
+#if 1
+               //def ENABLE_BUILD_FARM_HACKS
                {
+#if 1
                        /*
                         * In the build farm, we want erratic behaviour for
                         * async I/O times
@@ -343,6 +347,8 @@ static void aio_child_loop(int sockfd, struct mmap_area *map)
                         */
                        generate_random_buffer(&randval, sizeof(randval));
                        msecs = randval + 20;
+#endif
+                       msecs = lp_parm_int(snum, "aio_fork", "sleep", 0);
                        DEBUG(10, ("delaying for %u msecs\n", msecs));
                        smb_msleep(msecs);
                }
@@ -478,11 +484,12 @@ static struct files_struct *close_fsp_fd(struct files_struct *fsp,
        return NULL;
 }
 
-static NTSTATUS create_aio_child(struct smbd_server_connection *sconn,
+static NTSTATUS create_aio_child(struct connection_struct *conn,
                                 struct aio_child_list *children,
                                 size_t map_size,
                                 struct aio_child **presult)
 {
+       struct smbd_server_connection *sconn = conn->sconn;
        struct aio_child *result;
        int fdpair[2];
        NTSTATUS status;
@@ -518,7 +525,7 @@ static NTSTATUS create_aio_child(struct smbd_server_connection *sconn,
                close(fdpair[0]);
                result->sockfd = fdpair[1];
                files_forall(sconn, close_fsp_fd, NULL);
-               aio_child_loop(result->sockfd, result->map);
+               aio_child_loop(result->sockfd, result->map, SNUM(conn));
        }
 
        DEBUG(10, ("Child %d created with sockfd %d\n",
@@ -576,7 +583,7 @@ static NTSTATUS get_idle_child(struct vfs_handle_struct *handle,
        if (child == NULL) {
                DEBUG(10, ("no idle child found, creating new one\n"));
 
-               status = create_aio_child(handle->conn->sconn, children,
+               status = create_aio_child(handle->conn, children,
                                          128*1024, &child);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(10, ("create_aio_child failed: %s\n",