Revert "smbd: add an effective {smb,smbd_smb2}_request->ev_ctx that holds the event...
authorRalph Boehme <slow@samba.org>
Thu, 27 Dec 2018 14:18:55 +0000 (15:18 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 11 Jan 2019 22:11:16 +0000 (23:11 +0100)
This reverts commit 894e5001c747ce765dad5517778dda55d7d1f4d9.

See the discussion in

https://lists.samba.org/archive/samba-technical/2018-December/131731.html

for the reasoning behind this revert.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
25 files changed:
source3/include/vfs.h
source3/smbd/aio.c
source3/smbd/globals.h
source3/smbd/ipc.c
source3/smbd/open.c
source3/smbd/pipes.c
source3/smbd/process.c
source3/smbd/reply.c
source3/smbd/smb2_break.c
source3/smbd/smb2_close.c
source3/smbd/smb2_create.c
source3/smbd/smb2_flush.c
source3/smbd/smb2_getinfo.c
source3/smbd/smb2_glue.c
source3/smbd/smb2_ioctl.c
source3/smbd/smb2_ioctl_named_pipe.c
source3/smbd/smb2_lock.c
source3/smbd/smb2_notify.c
source3/smbd/smb2_query_directory.c
source3/smbd/smb2_read.c
source3/smbd/smb2_server.c
source3/smbd/smb2_sesssetup.c
source3/smbd/smb2_setinfo.c
source3/smbd/smb2_tcon.c
source3/smbd/smb2_write.c

index 959dd40..1a05283 100644 (file)
@@ -518,8 +518,6 @@ struct smb_request {
 
        size_t unread_bytes;
        bool encrypted;
-       /* the tevent_context (wrapper) the request operates on */
-       struct tevent_context *ev_ctx;
        connection_struct *conn;
        struct smbd_server_connection *sconn;
        struct smbXsrv_connection *xconn;
index 29723d2..8ac3ef7 100644 (file)
@@ -206,7 +206,7 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
        aio_ex->nbyte = smb_maxcnt;
        aio_ex->offset = startpos;
 
-       req = SMB_VFS_PREAD_SEND(aio_ex, smbreq->ev_ctx,
+       req = SMB_VFS_PREAD_SEND(aio_ex, fsp->conn->sconn->ev_ctx,
                                 fsp,
                                 smb_buf(aio_ex->outbuf.data) + 1 /* pad */,
                                 smb_maxcnt, startpos);
@@ -459,7 +459,7 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
        aio_ex->nbyte = numtowrite;
        aio_ex->offset = startpos;
 
-       req = pwrite_fsync_send(aio_ex, smbreq->ev_ctx, fsp,
+       req = pwrite_fsync_send(aio_ex, fsp->conn->sconn->ev_ctx, fsp,
                                data, numtowrite, startpos,
                                aio_ex->write_through);
        if (req == NULL) {
@@ -705,7 +705,7 @@ NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
        aio_ex->nbyte = smb_maxcnt;
        aio_ex->offset = startpos;
 
-       req = SMB_VFS_PREAD_SEND(aio_ex, smbreq->ev_ctx, fsp,
+       req = SMB_VFS_PREAD_SEND(aio_ex, fsp->conn->sconn->ev_ctx, fsp,
                                 preadbuf->data, smb_maxcnt, startpos);
        if (req == NULL) {
                DEBUG(0, ("smb2: SMB_VFS_PREAD_SEND failed. "
@@ -846,7 +846,7 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
        aio_ex->nbyte = in_data.length;
        aio_ex->offset = in_offset;
 
-       req = pwrite_fsync_send(aio_ex, smbreq->ev_ctx, fsp,
+       req = pwrite_fsync_send(aio_ex, fsp->conn->sconn->ev_ctx, fsp,
                                in_data.data, in_data.length, in_offset,
                                write_through);
        if (req == NULL) {
index a13916e..a273cdb 100644 (file)
@@ -705,9 +705,6 @@ struct smbd_smb2_request {
        struct smbXsrv_tcon *tcon;
        uint32_t last_tid;
 
-       /* the tevent_context (wrapper) the request operates on */
-       struct tevent_context *ev_ctx;
-
        int current_idx;
        bool do_signing;
        /* Was the request encrypted? */
index 85236e0..f1c8ea0 100644 (file)
@@ -281,7 +281,7 @@ static void api_dcerpc_cmd(connection_struct *conn, struct smb_request *req,
        state->num_data = length;
        state->max_read = max_read;
 
-       subreq = np_write_send(state, req->ev_ctx, state->handle,
+       subreq = np_write_send(state, req->sconn->ev_ctx, state->handle,
                               state->data, length);
        if (subreq == NULL) {
                TALLOC_FREE(state);
@@ -330,7 +330,7 @@ static void api_dcerpc_cmd_write_done(struct tevent_req *subreq)
                goto send;
        }
 
-       subreq = np_read_send(state, req->ev_ctx,
+       subreq = np_read_send(state, req->sconn->ev_ctx,
                              state->handle, state->data, state->max_read);
        if (subreq == NULL) {
                reply_nterror(req, NT_STATUS_NO_MEMORY);
index a3df8a1..bab9286 100644 (file)
@@ -2408,7 +2408,7 @@ static void defer_open(struct share_mode_lock *lck,
        DBG_DEBUG("defering mid %" PRIu64 "\n", req->mid);
 
        watch_req = dbwrap_watched_watch_send(watch_state,
-                                             req->ev_ctx,
+                                             req->sconn->ev_ctx,
                                              lck->data->record,
                                              (struct server_id){0});
        if (watch_req == NULL) {
@@ -2416,7 +2416,7 @@ static void defer_open(struct share_mode_lock *lck,
        }
        tevent_req_set_callback(watch_req, defer_open_done, watch_state);
 
-       ok = tevent_req_set_endtime(watch_req, req->ev_ctx, abs_timeout);
+       ok = tevent_req_set_endtime(watch_req, req->sconn->ev_ctx, abs_timeout);
        if (!ok) {
                exit_server("tevent_req_set_endtime failed");
        }
@@ -2508,7 +2508,7 @@ static void setup_kernel_oplock_poll_open(struct timeval request_time,
         * As this timer event is owned by req, it will
         * disappear if req it talloc_freed.
         */
-       open_rec->te = tevent_add_timer(req->ev_ctx,
+       open_rec->te = tevent_add_timer(req->sconn->ev_ctx,
                                        req,
                                        timeval_current_ofs(1, 0),
                                        kernel_oplock_poll_open_timer,
@@ -2695,7 +2695,7 @@ static void schedule_async_open(struct timeval request_time,
                exit_server("push_deferred_open_message_smb failed");
        }
 
-       open_rec->te = tevent_add_timer(req->ev_ctx,
+       open_rec->te = tevent_add_timer(req->sconn->ev_ctx,
                                        req,
                                        timeval_current_ofs(20, 0),
                                        schedule_async_open_timer,
index c945f0f..4be57bc 100644 (file)
@@ -67,7 +67,7 @@ NTSTATUS open_np_file(struct smb_request *smb_req, const char *name,
                         conn->sconn->remote_address,
                         conn->sconn->local_address,
                         conn->session_info,
-                        smb_req->ev_ctx,
+                        conn->sconn->ev_ctx,
                         conn->sconn->msg_ctx,
                         &fsp->fake_file_handle);
        if (!NT_STATUS_IS_OK(status)) {
@@ -206,7 +206,7 @@ void reply_pipe_write(struct smb_request *req)
        DEBUG(6, ("reply_pipe_write: %s, name: %s len: %d\n", fsp_fnum_dbg(fsp),
                  fsp_str_dbg(fsp), (int)state->numtowrite));
 
-       subreq = np_write_send(state, req->ev_ctx,
+       subreq = np_write_send(state, req->sconn->ev_ctx,
                               fsp->fake_file_handle, data, state->numtowrite);
        if (subreq == NULL) {
                TALLOC_FREE(state);
@@ -322,7 +322,7 @@ void reply_pipe_write_and_X(struct smb_request *req)
                state->numtowrite -= 2;
        }
 
-       subreq = np_write_send(state, req->ev_ctx,
+       subreq = np_write_send(state, req->sconn->ev_ctx,
                               fsp->fake_file_handle, data, state->numtowrite);
        if (subreq == NULL) {
                TALLOC_FREE(state);
@@ -435,7 +435,7 @@ void reply_pipe_read_and_X(struct smb_request *req)
        state->outbuf = req->outbuf;
        req->outbuf = NULL;
 
-       subreq = np_read_send(state, req->ev_ctx,
+       subreq = np_read_send(state, req->sconn->ev_ctx,
                              fsp->fake_file_handle, data,
                              state->smb_maxcnt);
        if (subreq == NULL) {
index e730676..d255304 100644 (file)
@@ -1506,8 +1506,6 @@ static connection_struct *switch_message(uint8_t type, struct smb_request *req)
 
        errno = 0;
 
-       req->ev_ctx = NULL;
-
        if (!xconn->smb1.negprot.done) {
                switch (type) {
                        /*
@@ -1642,8 +1640,6 @@ static connection_struct *switch_message(uint8_t type, struct smb_request *req)
                        reply_nterror(req, NT_STATUS_ACCESS_DENIED);
                        return conn;
                }
-
-               req->ev_ctx = conn->user_ev_ctx;
        } else if (flags & AS_GUEST) {
                /*
                 * Does this protocol need to be run as guest? (Only archane
@@ -1653,13 +1649,9 @@ static connection_struct *switch_message(uint8_t type, struct smb_request *req)
                        reply_nterror(req, NT_STATUS_ACCESS_DENIED);
                        return conn;
                }
-
-               req->ev_ctx = req->sconn->guest_ev_ctx;
        } else {
                /* This call needs to be run as root */
                change_to_root_user();
-
-               req->ev_ctx = req->sconn->root_ev_ctx;
        }
 
        /* load service specific parameters */
index f2617fa..405bd6c 100644 (file)
@@ -5417,7 +5417,7 @@ void reply_close(struct smb_request *req)
                 */
 
                fsp->deferred_close = tevent_wait_send(
-                       fsp, req->ev_ctx);
+                       fsp, fsp->conn->sconn->ev_ctx);
                if (fsp->deferred_close == NULL) {
                        status = NT_STATUS_NO_MEMORY;
                        goto done;
index ec9c0f1..ae6b921 100644 (file)
@@ -86,7 +86,7 @@ NTSTATUS smbd_smb2_request_process_break(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
        }
 
-       subreq = smbd_smb2_oplock_break_send(req, req->ev_ctx,
+       subreq = smbd_smb2_oplock_break_send(req, req->sconn->ev_ctx,
                                             req, in_fsp, in_oplock_level);
        if (subreq == NULL) {
                return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
@@ -265,7 +265,7 @@ static NTSTATUS smbd_smb2_request_process_lease_break(
        in_lease_key.data[1] = BVAL(inbody, 16);
        in_lease_state = IVAL(inbody, 24);
 
-       subreq = smbd_smb2_lease_break_send(req, req->ev_ctx, req,
+       subreq = smbd_smb2_lease_break_send(req, req->sconn->ev_ctx, req,
                                            in_lease_key, in_lease_state);
        if (subreq == NULL) {
                return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
index 1888736..dea9512 100644 (file)
@@ -70,7 +70,7 @@ NTSTATUS smbd_smb2_request_process_close(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
-       subreq = smbd_smb2_close_send(req, req->ev_ctx,
+       subreq = smbd_smb2_close_send(req, req->sconn->ev_ctx,
                                      req, in_fsp, in_flags);
        if (subreq == NULL) {
                return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
index fdd04ac..9de7cef 100644 (file)
@@ -228,7 +228,7 @@ NTSTATUS smbd_smb2_request_process_create(struct smbd_smb2_request *smb2req)
        }
 
        tsubreq = smbd_smb2_create_send(smb2req,
-                                      smb2req->ev_ctx,
+                                      smb2req->sconn->ev_ctx,
                                       smb2req,
                                       in_oplock_level,
                                       in_impersonation_level,
@@ -1759,7 +1759,7 @@ bool schedule_deferred_open_message_smb2(
                (unsigned long long)mid ));
 
        tevent_schedule_immediate(state->im,
-                       smb2req->ev_ctx,
+                       smb2req->sconn->ev_ctx,
                        smbd_smb2_create_request_dispatch_immediate,
                        smb2req);
 
@@ -1791,7 +1791,7 @@ static bool smbd_smb2_create_cancel(struct tevent_req *req)
 
        remove_deferred_open_message_smb2_internal(smb2req, mid);
 
-       tevent_req_defer_callback(req, smb2req->ev_ctx);
+       tevent_req_defer_callback(req, smb2req->sconn->ev_ctx);
        tevent_req_nterror(req, NT_STATUS_CANCELLED);
        return true;
 }
index 4f815a6..470a8df 100644 (file)
@@ -58,7 +58,7 @@ NTSTATUS smbd_smb2_request_process_flush(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
-       subreq = smbd_smb2_flush_send(req, req->ev_ctx,
+       subreq = smbd_smb2_flush_send(req, req->sconn->ev_ctx,
                                      req, in_fsp);
        if (subreq == NULL) {
                return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
index 314f44e..29625fc 100644 (file)
@@ -122,7 +122,7 @@ NTSTATUS smbd_smb2_request_process_getinfo(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
-       subreq = smbd_smb2_getinfo_send(req, req->ev_ctx,
+       subreq = smbd_smb2_getinfo_send(req, req->sconn->ev_ctx,
                                        req, in_fsp,
                                        in_info_type,
                                        in_file_info_class,
index cccc763..6a73ec0 100644 (file)
@@ -46,7 +46,6 @@ struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req)
        smbreq->conn = req->tcon->compat;
        smbreq->sconn = req->sconn;
        smbreq->xconn = req->xconn;
-       smbreq->ev_ctx = req->ev_ctx;
        smbreq->smbpid = (uint16_t)IVAL(inhdr, SMB2_HDR_PID);
        smbreq->flags2 = FLAGS2_UNICODE_STRINGS |
                         FLAGS2_32_BIT_ERROR_CODES |
index 451733c..be70e3a 100644 (file)
@@ -217,7 +217,7 @@ NTSTATUS smbd_smb2_request_process_ioctl(struct smbd_smb2_request *req)
                break;
        }
 
-       subreq = smbd_smb2_ioctl_send(req, req->ev_ctx,
+       subreq = smbd_smb2_ioctl_send(req, req->sconn->ev_ctx,
                                      req, in_fsp,
                                      in_ctl_code,
                                      in_input_buffer,
index f8012ae..f9e3dec 100644 (file)
@@ -143,7 +143,7 @@ static void smbd_smb2_ioctl_pipe_write_done(struct tevent_req *subreq)
                (unsigned int)state->out_output.length ));
 
        subreq = np_read_send(state->smbreq->conn,
-                             state->smb2req->ev_ctx,
+                             state->smb2req->sconn->ev_ctx,
                              state->fsp->fake_file_handle,
                              state->out_output.data,
                              state->out_output.length);
index da5a54d..3cc5910 100644 (file)
@@ -134,7 +134,7 @@ NTSTATUS smbd_smb2_request_process_lock(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
-       subreq = smbd_smb2_lock_send(req, req->ev_ctx,
+       subreq = smbd_smb2_lock_send(req, req->sconn->ev_ctx,
                                     req, in_fsp,
                                     in_lock_count,
                                     in_locks);
@@ -368,7 +368,7 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
        }
 
        if (async) {
-               tevent_req_defer_callback(req, smb2req->ev_ctx);
+               tevent_req_defer_callback(req, smb2req->sconn->ev_ctx);
                SMBPROFILE_IOBYTES_ASYNC_SET_IDLE(smb2req->profile);
                return req;
        }
index e49e76d..2424156 100644 (file)
@@ -94,7 +94,7 @@ NTSTATUS smbd_smb2_request_process_notify(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
-       subreq = smbd_smb2_notify_send(req, req->ev_ctx,
+       subreq = smbd_smb2_notify_send(req, req->sconn->ev_ctx,
                                       req, in_fsp,
                                       in_flags,
                                       in_output_buffer_length,
@@ -355,7 +355,7 @@ static void smbd_smb2_notify_reply(struct smb_request *smbreq,
                }
        }
 
-       tevent_req_defer_callback(req, state->smb2req->ev_ctx);
+       tevent_req_defer_callback(req, state->smb2req->sconn->ev_ctx);
 
        if (!NT_STATUS_IS_OK(state->status)) {
                tevent_req_nterror(req, state->status);
index ab6c3dc..a80c9f5 100644 (file)
@@ -125,7 +125,7 @@ NTSTATUS smbd_smb2_request_process_query_directory(struct smbd_smb2_request *req
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
-       subreq = smbd_smb2_query_directory_send(req, req->ev_ctx,
+       subreq = smbd_smb2_query_directory_send(req, req->sconn->ev_ctx,
                                     req, in_fsp,
                                     in_file_info_class,
                                     in_flags,
index 065a5cd..a7d2496 100644 (file)
@@ -97,7 +97,7 @@ NTSTATUS smbd_smb2_request_process_read(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
-       subreq = smbd_smb2_read_send(req, req->ev_ctx,
+       subreq = smbd_smb2_read_send(req, req->sconn->ev_ctx,
                                     req, in_fsp,
                                     in_flags,
                                     in_length,
index e36db1e..1e9ed33 100644 (file)
@@ -2620,10 +2620,8 @@ NTSTATUS smbd_smb2_request_dispatch(struct smbd_smb2_request *req)
                SMB_ASSERT(call->fileid_ofs == 0);
                /* This call needs to be run as root */
                change_to_root_user();
-               req->ev_ctx = req->sconn->root_ev_ctx;
        } else {
                SMB_ASSERT(call->need_tcon);
-               req->ev_ctx = req->tcon->compat->user_ev_ctx;
        }
 
 #define _INBYTES(_r) \
index 5420d4f..2c24e7a 100644 (file)
@@ -95,7 +95,7 @@ NTSTATUS smbd_smb2_request_process_sesssetup(struct smbd_smb2_request *smb2req)
        in_security_buffer.length = in_security_length;
 
        subreq = smbd_smb2_session_setup_wrap_send(smb2req,
-                                                  smb2req->ev_ctx,
+                                                  smb2req->sconn->ev_ctx,
                                                   smb2req,
                                                   in_session_id,
                                                   in_flags,
@@ -1218,7 +1218,7 @@ NTSTATUS smbd_smb2_request_process_logoff(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, status);
        }
 
-       subreq = smbd_smb2_logoff_send(req, req->ev_ctx, req);
+       subreq = smbd_smb2_logoff_send(req, req->sconn->ev_ctx, req);
        if (subreq == NULL) {
                return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
        }
index 7c1f84b..b19cbb1 100644 (file)
@@ -108,7 +108,7 @@ NTSTATUS smbd_smb2_request_process_setinfo(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
-       subreq = smbd_smb2_setinfo_send(req, req->ev_ctx,
+       subreq = smbd_smb2_setinfo_send(req, req->sconn->ev_ctx,
                                        req, in_fsp,
                                        in_info_type,
                                        in_file_info_class,
index 3a4a15d..ebd3160 100644 (file)
@@ -94,7 +94,7 @@ NTSTATUS smbd_smb2_request_process_tcon(struct smbd_smb2_request *req)
        }
 
        subreq = smbd_smb2_tree_connect_send(req,
-                                            req->ev_ctx,
+                                            req->sconn->ev_ctx,
                                             req,
                                             in_path_string);
        if (subreq == NULL) {
@@ -491,7 +491,7 @@ NTSTATUS smbd_smb2_request_process_tdis(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, status);
        }
 
-       subreq = smbd_smb2_tdis_send(req, req->ev_ctx, req);
+       subreq = smbd_smb2_tdis_send(req, req->sconn->ev_ctx, req);
        if (subreq == NULL) {
                return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
        }
index d5ab12e..ee95bd3 100644 (file)
@@ -109,7 +109,7 @@ NTSTATUS smbd_smb2_request_process_write(struct smbd_smb2_request *req)
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
-       subreq = smbd_smb2_write_send(req, req->ev_ctx,
+       subreq = smbd_smb2_write_send(req, req->sconn->ev_ctx,
                                      req, in_fsp,
                                      in_data_buffer,
                                      in_offset,