summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCsaba Henk <csaba@redhat.com>2012-06-13 14:15:14 +0530
committerVijay Bellur <vbellur@redhat.com>2012-10-31 09:46:54 -0400
commit371f778ecb71bec24391b1dfac4a30cd3ba059d7 (patch)
tree9ded8f168fd244cb226b1babc6a5521e38483b50
parente336ccf879605adef133aaefd69d9877c47d96e2 (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: 870502 Change-Id: I3c39e718e72545c27d50fd73aa6daf54062331b0 Reviewed-on: https://code.engineering.redhat.com/gerrit/167 Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-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 ae6cf26a6d8..7eced825c22 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)