summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2019-08-10 14:44:08 +0200
committerJeremy Allison <jra@samba.org>2019-08-19 23:14:38 +0000
commit9034cb39d7c0d8d6387f4977f894349db187d6b5 (patch)
tree08fde882cbb71fb527bdc0706823429951ede9d8
parent38463a91aafa2643551b4e4508c3e575d9e914a1 (diff)
downloadsamba-9034cb39d7c0d8d6387f4977f894349db187d6b5.tar.gz
smbd: Optimize delay_for_oplock()
get_lease_type() can involve a database access. Do that only if necessary, and that is at most once in this loop. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org>
-rw-r--r--source3/smbd/open.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 1fd2cb721f4..a28f70fbc41 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2264,9 +2264,6 @@ static NTSTATUS grant_fsp_oplock_type(struct smb_request *req,
for (i=0; i<d->num_share_modes; i++) {
struct share_mode_entry *e = &d->share_modes[i];
- uint32_t e_lease_type;
-
- e_lease_type = get_lease_type(d, e);
if ((granted & SMB2_LEASE_WRITE) &&
!is_same_lease(fsp, d, e, lease) &&
@@ -2277,9 +2274,12 @@ static NTSTATUS grant_fsp_oplock_type(struct smb_request *req,
granted &= ~SMB2_LEASE_WRITE;
}
- if ((e_lease_type & SMB2_LEASE_HANDLE) && !got_handle_lease &&
- !share_mode_stale_pid(d, i)) {
- got_handle_lease = true;
+ if (!got_handle_lease) {
+ uint32_t e_lease_type = get_lease_type(d, e);
+ if ((e_lease_type & SMB2_LEASE_HANDLE) &&
+ !share_mode_stale_pid(d, i)) {
+ got_handle_lease = true;
+ }
}
if ((e->op_type != LEASE_OPLOCK) && !got_oplock &&