summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2017-03-07 15:48:05 +0100
committerKarolin Seeger <kseeger@samba.org>2017-03-14 12:49:24 +0100
commitec6794d270d0b342f976f0a76675112c02ae5d12 (patch)
tree980450962a4cdcd2d8725d96dce76bdff7dfbfa6
parent9bbccbb1d29298235744537cd6a68845b3f60e13 (diff)
downloadsamba-ec6794d270d0b342f976f0a76675112c02ae5d12.tar.gz
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 <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (backported from commit 1a6c82e5d5a3462827ee3fe1edab01f535f831a9)
-rw-r--r--source3/smbd/open.c64
1 files changed, 33 insertions, 31 deletions
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");
}