From: Ralph Boehme Date: Tue, 7 Mar 2017 14:48:05 +0000 (+0100) Subject: s3/smbd: all callers of defer_open() pass a lck X-Git-Tag: samba-4.4.11~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec6794d270d0b342f976f0a76675112c02ae5d12;p=thirdparty%2Fsamba.git s3/smbd: all callers of defer_open() pass a lck No change in behaviour. Update the function comment explaining how it works and relies on lck for a record watch. Bug: https://bugzilla.samba.org/show_bug.cgi?id=7537 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (backported from commit 1a6c82e5d5a3462827ee3fe1edab01f535f831a9) --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index cfe91357777..a2fda6d3f9e 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1948,10 +1948,15 @@ struct defer_open_state { static void defer_open_done(struct tevent_req *req); -/**************************************************************************** - Handle the 1 second delay in returning a SHARING_VIOLATION error. -****************************************************************************/ - +/** + * Defer an open and watch a locking.tdb record + * + * This defers an open that gets rescheduled once the locking.tdb record watch + * is triggered by a change to the record. + * + * It is used to defer opens that triggered an oplock break and for the SMB1 + * sharing violation delay. + **/ static void defer_open(struct share_mode_lock *lck, struct timeval request_time, struct timeval timeout, @@ -1961,6 +1966,9 @@ static void defer_open(struct share_mode_lock *lck, { struct deferred_open_record *open_rec = NULL; struct timeval abs_timeout; + struct defer_open_state *watch_state; + struct tevent_req *watch_req; + bool ok; abs_timeout = timeval_sum(&request_time, &timeout); @@ -1980,38 +1988,32 @@ static void defer_open(struct share_mode_lock *lck, exit_server("talloc failed"); } - if (lck) { - struct defer_open_state *watch_state; - struct tevent_req *watch_req; - bool ret; - - watch_state = talloc(open_rec, struct defer_open_state); - if (watch_state == NULL) { - exit_server("talloc failed"); - } - watch_state->xconn = req->xconn; - watch_state->mid = req->mid; + watch_state = talloc(open_rec, struct defer_open_state); + if (watch_state == NULL) { + exit_server("talloc failed"); + } + watch_state->xconn = req->xconn; + watch_state->mid = req->mid; - DEBUG(10, ("defering mid %llu\n", - (unsigned long long)req->mid)); + DBG_DEBUG("defering mid %" PRIu64 "\n", req->mid); - watch_req = dbwrap_record_watch_send( - watch_state, req->sconn->ev_ctx, lck->data->record, - req->sconn->msg_ctx); - if (watch_req == NULL) { - exit_server("Could not watch share mode record"); - } - tevent_req_set_callback(watch_req, defer_open_done, - watch_state); + watch_req = dbwrap_record_watch_send( + watch_state, req->sconn->ev_ctx, lck->data->record, + req->sconn->msg_ctx); + if (watch_req == NULL) { + exit_server("Could not watch share mode record"); + } + tevent_req_set_callback(watch_req, defer_open_done, + watch_state); - ret = tevent_req_set_endtime( - watch_req, req->sconn->ev_ctx, - abs_timeout); - SMB_ASSERT(ret); + ok = tevent_req_set_endtime(watch_req, req->sconn->ev_ctx, abs_timeout); + if (!ok) { + exit_server("tevent_req_set_endtime failed"); } - if (!push_deferred_open_message_smb(req, request_time, timeout, - open_rec->id, open_rec)) { + ok = push_deferred_open_message_smb(req, request_time, timeout, + open_rec->id, open_rec); + if (!ok) { TALLOC_FREE(lck); exit_server("push_deferred_open_message_smb failed"); }