summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCsaba Henk <csaba@redhat.com>2012-06-13 14:15:14 +0530
committerVijay Bellur <vbellur@redhat.com>2012-07-16 02:50:28 -0700
commit01b365d5bba3bea0847bc79fb5dfe82e5c75dc91 (patch)
tree29a19a9ae3e8045e89fc13484d9feabce4c1fd99
parentc0a5348af37c634cc61fa72251e029a3a0301eca (diff)
geo-rep / gsyncd: fixes to communication with child processes
due to not using the proper Python keyword, errhandler thread was possible to run into empty select Signed-off-by: Csaba Henk <csaba@redhat.com> BUG: 764678 Change-Id: I3c39e718e72545c27d50fd73aa6daf54062331b0 Reviewed-on: http://review.gluster.com/3562 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/features/marker/utils/syncdaemon/resource.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/resource.py b/xlators/features/marker/utils/syncdaemon/resource.py
index 9f4c5f74463..f09ac875403 100644
--- a/xlators/features/marker/utils/syncdaemon/resource.py
+++ b/xlators/features/marker/utils/syncdaemon/resource.py
@@ -125,12 +125,12 @@ class Popen(subprocess.Popen):
continue
for po in errstore:
if po.stderr not in poe:
- next
+ continue
po.lock.acquire()
try:
- la = errstore.get(po)
- if la == None:
+ if po.on_death_row:
continue
+ la = errstore[po]
try:
fd = po.stderr.fileno()
except ValueError: # file is already closed
@@ -169,6 +169,7 @@ class Popen(subprocess.Popen):
if 'close_fds' not in kw:
kw['close_fds'] = True
self.lock = threading.Lock()
+ self.on_death_row = False
try:
sup(self, args, *a, **kw)
except:
@@ -177,7 +178,7 @@ class Popen(subprocess.Popen):
raise
raise GsyncdError("""execution of "%s" failed with %s (%s)""" % \
(args[0], errno.errorcode[ex.errno], os.strerror(ex.errno)))
- if kw['stderr'] == subprocess.PIPE:
+ if kw.get('stderr') == subprocess.PIPE:
assert(getattr(self, 'errhandler', None))
self.errstore[self] = []
@@ -212,16 +213,19 @@ class Popen(subprocess.Popen):
"""
self.lock.acquire()
try:
- elines = self.errstore.pop(self)
+ self.on_death_row = True
finally:
self.lock.release()
+ elines = self.errstore.pop(self)
if self.poll() == None:
self.terminate()
if self.poll() == None:
time.sleep(0.1)
- self.kill()
- self.wait()
+ self.kill()
+ self.wait()
while True:
+ if not select([self.stderr],[],[],0.1)[0]:
+ break
b = os.read(self.stderr.fileno(), 1024)
if b:
elines.append(b)