summaryrefslogtreecommitdiffstats
path: root/geo-replication/syncdaemon
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-06-19 01:41:27 +0530
committerVenky Shankar <vshankar@redhat.com>2015-07-05 23:50:26 -0700
commit33935401cc548b55afc8ed907e54f72ff3e567b4 (patch)
tree436aee30a23ee7e276a40fcdd5fb2fc6239a0d16 /geo-replication/syncdaemon
parentadc704557a141a624fc702f7303b8b81582e1598 (diff)
geo-rep: Fix fd referenced before assignment
Fix fd reference before assignment in mgmt_lock function. Change-Id: Ie939d4262a59cae0817ae388658a000576ab69b8 BUG: 1233411 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/11318 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'geo-replication/syncdaemon')
-rw-r--r--geo-replication/syncdaemon/master.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py
index 37be4fc3adc..5b8abc5fd9f 100644
--- a/geo-replication/syncdaemon/master.py
+++ b/geo-replication/syncdaemon/master.py
@@ -442,6 +442,7 @@ class GMasterCommon(object):
def mgmt_lock(self):
"""Take management volume lock """
+ fd = None
bname = str(self.uuid) + "_" + str(gconf.slave_id) + "_subvol_" \
+ str(gconf.subvol_num) + ".lock"
mgmt_lock_dir = os.path.join(gconf.meta_volume_mnt, "geo-rep")
@@ -455,18 +456,21 @@ class GMasterCommon(object):
logging.info("Creating geo-rep directory in meta volume...")
try:
os.makedirs(mgmt_lock_dir)
- fd = os.open(path, os.O_CREAT | os.O_RDWR)
except OSError:
ex = sys.exc_info()[1]
if ex.errno == EEXIST:
pass
else:
raise
+ fd = os.open(path, os.O_CREAT | os.O_RDWR)
+ else:
+ raise
try:
fcntl.lockf(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
except:
ex = sys.exc_info()[1]
- os.close(fd)
+ if fd:
+ os.close(fd)
if isinstance(ex, IOError) and ex.errno in (EACCES, EAGAIN):
# cannot grab, it's taken
logging.debug("Lock held by someother worker process")