diff options
author | Volker Lendecke <vl@samba.org> | 2013-08-20 11:58:15 +0000 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-10-15 23:42:41 +0200 |
commit | 388bf3643d4c0254dbc6e9f77b15a8911405c4e6 (patch) | |
tree | 91b1428b3a0fe615588e80f17ed1dbfd8d0704b5 | |
parent | c33015c069de285cf6e14bacb1e3a7937e466ef3 (diff) | |
download | samba-388bf3643d4c0254dbc6e9f77b15a8911405c4e6.tar.gz samba-388bf3643d4c0254dbc6e9f77b15a8911405c4e6.tar.bz2 samba-388bf3643d4c0254dbc6e9f77b15a8911405c4e6.zip |
smbd: Unify delay_for_*_oplocks
This is the same code in both routines
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
-rw-r--r-- | source3/smbd/open.c | 58 |
1 files changed, 13 insertions, 45 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 29c6eb525d..fa7c4a0b0f 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1297,19 +1297,19 @@ static void find_oplock_types(files_struct *fsp, } } -static bool delay_for_batch_oplocks(files_struct *fsp, - uint64_t mid, - int oplock_request, - struct share_mode_entry *batch_entry) +static bool delay_for_oplock(files_struct *fsp, + uint64_t mid, + int oplock_request, + struct share_mode_entry *entry) { if ((oplock_request & INTERNAL_OPEN_ONLY) || is_stat_open(fsp->access_mask)) { return false; } - if (batch_entry == NULL) { + if (entry == NULL) { return false; } - if (server_id_is_disconnected(&batch_entry->pid)) { + if (server_id_is_disconnected(&entry->pid)) { /* * TODO: clean up. * This could be achieved by sending a break message @@ -1322,33 +1322,7 @@ static bool delay_for_batch_oplocks(files_struct *fsp, return false; } - /* Found a batch oplock */ - send_break_message(fsp, batch_entry, mid, oplock_request); - return true; -} - -static bool delay_for_exclusive_oplocks(files_struct *fsp, - uint64_t mid, - int oplock_request, - struct share_mode_entry *ex_entry) -{ - if ((oplock_request & INTERNAL_OPEN_ONLY) || is_stat_open(fsp->access_mask)) { - return false; - } - if (ex_entry == NULL) { - return false; - } - - if (server_id_is_disconnected(&ex_entry->pid)) { - /* - * since only durable handles can get disconnected, - * and we can only get durable handles with batch oplocks, - * this should actually never be reached... - */ - return false; - } - - send_break_message(fsp, ex_entry, mid, oplock_request); + send_break_message(fsp, entry, mid, oplock_request); return true; } @@ -2313,9 +2287,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, find_oplock_types(fsp, 0, lck, &batch_entry, &exclusive_entry, &got_level2_oplock, &got_a_none_oplock); - if (delay_for_batch_oplocks(fsp, req->mid, 0, batch_entry) || - delay_for_exclusive_oplocks(fsp, req->mid, 0, - exclusive_entry)) { + if (delay_for_oplock(fsp, req->mid, 0, batch_entry) || + delay_for_oplock(fsp, req->mid, 0, exclusive_entry)) { schedule_defer_open(lck, request_time, req); TALLOC_FREE(lck); DEBUG(10, ("Sent oplock break request to kernel " @@ -2415,10 +2388,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, /* First pass - send break only on batch oplocks. */ if ((req != NULL) && - delay_for_batch_oplocks(fsp, - req->mid, - oplock_request, - batch_entry)) { + delay_for_oplock(fsp, req->mid, oplock_request, + batch_entry)) { schedule_defer_open(lck, request_time, req); TALLOC_FREE(lck); fd_close(fsp); @@ -2435,11 +2406,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, /* Second pass - send break for both batch or * exclusive oplocks. */ if ((req != NULL) && - delay_for_exclusive_oplocks( - fsp, - req->mid, - oplock_request, - exclusive_entry)) { + delay_for_oplock(fsp, req->mid, oplock_request, + exclusive_entry)) { schedule_defer_open(lck, request_time, req); TALLOC_FREE(lck); fd_close(fsp); |