summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/fd-lk.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/fd-lk.c')
-rw-r--r--libglusterfs/src/fd-lk.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/libglusterfs/src/fd-lk.c b/libglusterfs/src/fd-lk.c
index 32f3e0ad0..caf2bb38e 100644
--- a/libglusterfs/src/fd-lk.c
+++ b/libglusterfs/src/fd-lk.c
@@ -1,20 +1,11 @@
/*
- Copyright (c) 2011-2012 Gluster, Inc. <http://www.gluster.com>
+ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
This file is part of GlusterFS.
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
*/
#include "fd-lk.h"
@@ -378,7 +369,7 @@ _fd_lk_insert_and_merge (fd_lk_ctx_t *lk_ctx,
if (entry->fl_type == lock->fl_type) {
sum = _fd_lk_add_locks (entry, lock);
- if (sum)
+ if (!sum)
return;
sum->fl_type = entry->fl_type;
sum->user_flock.l_type = entry->fl_type;
@@ -389,8 +380,8 @@ _fd_lk_insert_and_merge (fd_lk_ctx_t *lk_ctx,
return;
} else {
sum = _fd_lk_add_locks (entry, lock);
- sum->fl_type = entry->fl_type;
- sum->user_flock.l_type = entry->fl_type;
+ sum->fl_type = lock->fl_type;
+ sum->user_flock.l_type = lock->fl_type;
ret = _fd_lk_sub_locks (&v, sum, lock);
if (ret)
return;
@@ -400,6 +391,8 @@ _fd_lk_insert_and_merge (fd_lk_ctx_t *lk_ctx,
_fd_lk_delete_lock (lock);
_fd_lk_destroy_lock (lock);
+ _fd_lk_destroy_lock (sum);
+
for (i = 0; i < 3; i++) {
if (!v.locks[i])
continue;
@@ -416,7 +409,7 @@ _fd_lk_insert_and_merge (fd_lk_ctx_t *lk_ctx,
if (lock->fl_type != F_UNLCK) {
_fd_lk_insert_lock (lk_ctx, lock);
} else {
- _fd_lk_destroy_lock_list (lk_ctx);
+ _fd_lk_destroy_lock (lock);
}
}
@@ -477,3 +470,21 @@ fd_lk_insert_and_merge (fd_t *fd, int32_t cmd,
out:
return ret;
}
+
+
+gf_boolean_t
+fd_lk_ctx_empty (fd_lk_ctx_t *lk_ctx)
+{
+ gf_boolean_t verdict = _gf_true;
+
+ if (!lk_ctx)
+ return _gf_true;
+
+ LOCK (&lk_ctx->lock);
+ {
+ verdict = list_empty (&lk_ctx->lk_list);
+ }
+ UNLOCK (&lk_ctx->lock);
+
+ return verdict;
+}