smbd: Avoid checking the_lock->id for fresh locks
authorVolker Lendecke <vl@samba.org>
Thu, 20 Mar 2014 13:53:14 +0000 (14:53 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 21 Mar 2014 18:20:17 +0000 (19:20 +0100)
If we just fetched the lock, this check will always be true.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/share_mode_lock.c

index 5d0874c3be1301e86abb10ba70371775e4af9c82..a34f3043b1dcaaf88d6cc98614d01a05725f2e83 100644 (file)
@@ -385,15 +385,16 @@ struct share_mode_lock *get_share_mode_lock(
                }
                talloc_set_destructor(the_lock, the_lock_destructor);
        } else {
+               if (!file_id_equal(&the_lock->data->id, &id)) {
+                       DEBUG(1, ("Can not lock two share modes "
+                                 "simultaneously\n"));
+                       goto fail;
+               }
                if (talloc_reference(lck, the_lock) == NULL) {
                        DEBUG(1, ("talloc_reference failed\n"));
                        goto fail;
                }
        }
-       if (!file_id_equal(&the_lock->data->id, &id)) {
-               DEBUG(1, ("Can not lock two share modes simultaneously\n"));
-               goto fail;
-       }
        lck->data = the_lock->data;
        return lck;
 fail: