summaryrefslogtreecommitdiffstats
path: root/geo-replication
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-06-19 01:41:27 +0530
committerVenky Shankar <vshankar@redhat.com>2015-07-12 19:48:02 -0700
commitf9a3cce2f52e249c0b836050a7f408f77e7d74c9 (patch)
tree25ac97f9c6b1bf5018368774948e755c138bd82f /geo-replication
parent7c1330d38cfeda93ab35b014b59e404b7b3d8ff4 (diff)
geo-rep: Fix fd referenced before assignment
Fix fd reference before assignment in mgmt_lock function. BUG: 1240607 Change-Id: Ib8a5207a516eecb55a5f906ff5d49abc98cab2a6 Reviewed-on: http://review.gluster.org/11318 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/11563 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Saravanakumar Arumugam <sarumuga@redhat.com> Reviewed-by: Milind Changire <mchangir@redhat.com> Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'geo-replication')
-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 37be4fc..5b8abc5 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")