s3: Move the aio signal init to the vfs module
authorVolker Lendecke <vl@samba.org>
Sun, 8 Apr 2012 18:11:53 +0000 (20:11 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 9 Apr 2012 16:04:55 +0000 (18:04 +0200)
On platforms that don't have an RT signal space, signal initialization
fails. aio_fork and aio_pthread don't need the signal, so this would
block them from running as well.

source3/modules/vfs_default.c
source3/smbd/aio.c
source3/smbd/proto.h

index 915eae67d3d23b060e09b61424e02407c6d55899..dd5441740adb9d916bd5234f748663c4e7c5f550 100644 (file)
@@ -2059,6 +2059,10 @@ static int vfswrap_fsetxattr(struct vfs_handle_struct *handle, struct files_stru
 static int vfswrap_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
 {
        int ret;
+       if (!initialize_async_io_handler()) {
+               errno = ENOSYS;
+               return -1;
+       }
        /*
         * aio_read must be done as root, because in the glibc aio
         * implementation the helper thread needs to be able to send a signal
@@ -2074,6 +2078,10 @@ static int vfswrap_aio_read(struct vfs_handle_struct *handle, struct files_struc
 static int vfswrap_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
 {
        int ret;
+       if (!initialize_async_io_handler()) {
+               errno = ENOSYS;
+               return -1;
+       }
        /*
         * aio_write must be done as root, because in the glibc aio
         * implementation the helper thread needs to be able to send a signal
index 000206a9852e571157a91c71e598b570c71028f8..e5347a45a4a7dabd9d12e8ffe5f22338a16d9e06 100644 (file)
@@ -71,7 +71,7 @@ static void smbd_aio_signal_handler(struct tevent_context *ev_ctx,
 }
 
 
-static bool initialize_async_io_handler(void)
+bool initialize_async_io_handler(void)
 {
        static bool tried_signal_setup = false;
 
@@ -156,11 +156,6 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
        size_t min_aio_read_size = lp_aio_read_size(SNUM(conn));
        int ret;
 
-       /* Ensure aio is initialized. */
-       if (!initialize_async_io_handler()) {
-               return NT_STATUS_RETRY;
-       }
-
        if (fsp->base_fsp != NULL) {
                /* No AIO on streams yet */
                DEBUG(10, ("AIO on streams not yet supported\n"));
@@ -263,11 +258,6 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
        size_t min_aio_write_size = lp_aio_write_size(SNUM(conn));
        int ret;
 
-       /* Ensure aio is initialized. */
-       if (!initialize_async_io_handler()) {
-               return NT_STATUS_RETRY;
-       }
-
        if (fsp->base_fsp != NULL) {
                /* No AIO on streams yet */
                DEBUG(10, ("AIO on streams not yet supported\n"));
@@ -426,11 +416,6 @@ NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
        size_t min_aio_read_size = lp_aio_read_size(SNUM(conn));
        int ret;
 
-       /* Ensure aio is initialized. */
-       if (!initialize_async_io_handler()) {
-               return NT_STATUS_RETRY;
-       }
-
        if (fsp->base_fsp != NULL) {
                /* No AIO on streams yet */
                DEBUG(10, ("AIO on streams not yet supported\n"));
@@ -532,11 +517,6 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
        size_t min_aio_write_size = lp_aio_write_size(SNUM(conn));
        int ret;
 
-       /* Ensure aio is initialized. */
-       if (!initialize_async_io_handler()) {
-               return NT_STATUS_RETRY;
-       }
-
        if (fsp->base_fsp != NULL) {
                /* No AIO on streams yet */
                DEBUG(10, ("AIO on streams not yet supported\n"));
@@ -1058,6 +1038,12 @@ void cancel_aio_by_fsp(files_struct *fsp)
 }
 
 #else
+
+bool initialize_async_io_handler(void)
+{
+       return false;
+}
+
 NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
                             struct smb_request *smbreq,
                             files_struct *fsp, off_t startpos,
index ca267a05008b3736f98fb49c4ab6b7a30cda2ea4..5ab51850873406b448dcfa9bf35b43bb2318483a 100644 (file)
@@ -64,6 +64,7 @@ void srv_set_signing(struct smbd_server_connection *conn,
 
 /* The following definitions come from smbd/aio.c  */
 
+bool initialize_async_io_handler(void);
 NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
                             struct smb_request *req,
                             files_struct *fsp, off_t startpos,