summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-07-10 22:23:37 +0200
committerStefan Metzmacher <metze@samba.org>2014-07-22 15:32:39 +0200
commit164e0cb23cd2e30d4cd2cb4ca2bad32e885bb754 (patch)
tree56234c8bc3bcc3ba6dbc7fa09e8d6402b2745277
parentff9a0a8993bdb3bd18b246a890b76d005ce0bb63 (diff)
downloadsamba-164e0cb23cd2e30d4cd2cb4ca2bad32e885bb754.tar.gz
samba-164e0cb23cd2e30d4cd2cb4ca2bad32e885bb754.tar.xz
samba-164e0cb23cd2e30d4cd2cb4ca2bad32e885bb754.zip
smbd: Simplify strict_lock_default with early returns
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--source3/locking/locking.c58
1 files changed, 24 insertions, 34 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index dd6c15ff91..1c0659ac04 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -103,6 +103,7 @@ void init_strict_lock_struct(files_struct *fsp,
bool strict_lock_default(files_struct *fsp, struct lock_struct *plock)
{
+ struct byte_range_lock *br_lck;
int strict_locking = lp_strict_locking(fsp->conn->params);
bool ret = False;
@@ -115,44 +116,33 @@ bool strict_lock_default(files_struct *fsp, struct lock_struct *plock)
}
if (strict_locking == Auto) {
- if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && (plock->lock_type == READ_LOCK || plock->lock_type == WRITE_LOCK)) {
- DEBUG(10,("is_locked: optimisation - exclusive oplock on file %s\n", fsp_str_dbg(fsp)));
- ret = True;
- } else if ((fsp->oplock_type == LEVEL_II_OPLOCK) &&
- (plock->lock_type == READ_LOCK)) {
- DEBUG(10,("is_locked: optimisation - level II oplock on file %s\n", fsp_str_dbg(fsp)));
- ret = True;
- } else {
- struct byte_range_lock *br_lck;
-
- br_lck = brl_get_locks_readonly(fsp);
- if (!br_lck) {
- return True;
- }
- ret = brl_locktest(br_lck,
- plock->context.smblctx,
- plock->context.pid,
- plock->start,
- plock->size,
- plock->lock_type,
- plock->lock_flav);
+ if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) &&
+ (plock->lock_type == READ_LOCK ||
+ plock->lock_type == WRITE_LOCK)) {
+ DEBUG(10, ("is_locked: optimisation - exclusive oplock "
+ "on file %s\n", fsp_str_dbg(fsp)));
+ return true;
}
- } else {
- struct byte_range_lock *br_lck;
-
- br_lck = brl_get_locks_readonly(fsp);
- if (!br_lck) {
- return True;
+ if ((fsp->oplock_type == LEVEL_II_OPLOCK) &&
+ (plock->lock_type == READ_LOCK)) {
+ DEBUG(10, ("is_locked: optimisation - level II oplock "
+ "on file %s\n", fsp_str_dbg(fsp)));
+ return true;
}
- ret = brl_locktest(br_lck,
- plock->context.smblctx,
- plock->context.pid,
- plock->start,
- plock->size,
- plock->lock_type,
- plock->lock_flav);
}
+ br_lck = brl_get_locks_readonly(fsp);
+ if (!br_lck) {
+ return true;
+ }
+ ret = brl_locktest(br_lck,
+ plock->context.smblctx,
+ plock->context.pid,
+ plock->start,
+ plock->size,
+ plock->lock_type,
+ plock->lock_flav);
+
DEBUG(10, ("strict_lock_default: flavour = %s brl start=%ju "
"len=%ju %s for fnum %ju file %s\n",
lock_flav_name(plock->lock_flav),