From: Volker Lendecke Date: Sat, 10 Aug 2019 12:44:08 +0000 (+0200) Subject: smbd: Optimize delay_for_oplock() X-Git-Tag: tdb-1.4.2~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9034cb39d7c0d8d6387f4977f894349db187d6b5;p=thirdparty%2Fsamba.git 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 Reviewed-by: Ralph Böhme --- 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; inum_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 &&