summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCsaba Henk <csaba@redhat.com>2012-04-20 17:21:12 +0200
committerVijay Bellur <vijay@gluster.com>2012-05-22 11:25:23 -0700
commit7a9a28742a7dffa8cc16866e9e3388f392e0e3b2 (patch)
tree2563712e39ded53b8d44e9ab1db92adc01507810
parent258b0f9b2e73d560774d80bd4724155e550ea31b (diff)
geo-rep / gsyncd: fixes regarding the command invocation framework
Some of the bugs to fix were found by the following stress-test: make "glusterfs --client-pid=-1" exit immediately on slave side. Also fix eintr_wrap which should not "adopt" exceptions generated by the wrapped call, by re-raising them as GsyncdError. Change-Id: Ia0d39e0635975ebbbf98d86e1e26f3122e1ed6ff BUG: 764678 Signed-off-by: Csaba Henk <csaba@redhat.com> Reviewed-on: http://review.gluster.com/3258 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Venky Shankar <vshankar@redhat.com> Reviewed-on: http://review.gluster.com/3409 Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r--xlators/features/marker/utils/syncdaemon/resource.py32
-rw-r--r--xlators/features/marker/utils/syncdaemon/syncdutils.py2
2 files changed, 25 insertions, 9 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/resource.py b/xlators/features/marker/utils/syncdaemon/resource.py
index c850e1fe313..923cf78d4cd 100644
--- a/xlators/features/marker/utils/syncdaemon/resource.py
+++ b/xlators/features/marker/utils/syncdaemon/resource.py
@@ -11,6 +11,7 @@ import tempfile
import threading
import subprocess
from errno import EEXIST, ENOENT, ENODATA, ENOTDIR, ELOOP, EISDIR
+from select import error as selecterror
from gconf import gconf
import repce
@@ -116,18 +117,32 @@ class Popen(subprocess.Popen):
cls.errstore = {}
def tailer():
while True:
- for po in select([po.stderr for po in cls.errstore], [], []):
+ errstore = cls.errstore.copy()
+ try:
+ poe, _ ,_ = select([po.stderr for po in errstore], [], [], 1)
+ except ValueError, selecterror:
+ continue
+ for po in errstore:
+ if po.stderr not in poe:
+ next
po.lock.acquire()
try:
- la = cls.errstore.get(po)
+ la = errstore.get(po)
if la == None:
continue
- l = os.read(po.stderr.fileno(), 1024)
+ try:
+ fd = po.stderr.fileno()
+ except ValueError: # file is already closed
+ continue
+ l = os.read(fd, 1024)
+ if not l:
+ continue
tots = len(l)
for lx in la:
tots += len(lx)
while tots > 1<<20 and la:
tots -= len(la.pop(0))
+ la.append(l)
finally:
po.lock.release()
t = syncdutils.Thread(target = tailer)
@@ -159,11 +174,11 @@ class Popen(subprocess.Popen):
def errfail(self):
"""fail nicely if child did not terminate with success"""
- filling = None
+ filling = ""
if self.elines:
filling = ", saying:"
- logging.error("""command "%s" returned with %d%s""" % \
- (" ".join(self.args), self.returncode, filling))
+ logging.error("""command "%s" returned with %s%s""" % \
+ (" ".join(self.args), repr(self.returncode), filling))
for l in self.elines:
for ll in l.rstrip().split("\n"):
logging.error(self.args[0] + "> " + ll.rstrip())
@@ -181,9 +196,10 @@ class Popen(subprocess.Popen):
self.lock.release()
if self.poll() == None:
self.terminate()
- if sp.poll() == None:
+ if self.poll() == None:
time.sleep(0.1)
- sp.kill()
+ self.kill()
+ self.wait()
while True:
b = os.read(self.stderr.fileno(), 1024)
if b:
diff --git a/xlators/features/marker/utils/syncdaemon/syncdutils.py b/xlators/features/marker/utils/syncdaemon/syncdutils.py
index 11c2063b750..c0f0ddd481a 100644
--- a/xlators/features/marker/utils/syncdaemon/syncdutils.py
+++ b/xlators/features/marker/utils/syncdaemon/syncdutils.py
@@ -264,7 +264,7 @@ def eintr_wrap(func, exc, *a):
except exc:
ex = sys.exc_info()[1]
if not ex.args[0] == EINTR:
- raise GsyncdError(ex.args[1])
+ raise
def select(*a):
return eintr_wrap(oselect.select, oselect.error, *a)