Commit 9aa7efc6 authored by alina's avatar alina

bigfix: protocol.clean can be call many times, try/execpt was added when...

bigfix: protocol.clean can be call many times, try/execpt was added when attempting to poll allready polled childs.
parent a3d74c0f
...@@ -94,28 +94,40 @@ class Server(object): ...@@ -94,28 +94,40 @@ class Server(object):
self._wfd = _get_file(wfd, "w") self._wfd = _get_file(wfd, "w")
def clean(self): def clean(self):
for pid in self._children: try:
os.kill(pid, signal.SIGTERM)
now = time.time()
while time.time() - now < KILL_WAIT:
ch = []
for pid in self._children: for pid in self._children:
if not netns.subprocess_.poll(pid): os.kill(pid, signal.SIGTERM)
ch.append(pid) now = time.time()
if not ch: ch = self._children
break while time.time() - now < KILL_WAIT:
time.sleep(0.1) for pid in set(ch):
for pid in ch: try:
warning("Killing forcefully process %d." % pid) if netns.subprocess_.poll(pid):
os.kill(pid, signal.SIGKILL) ch.remove(pid)
for pid in ch: except OSError, e:
netns.subprocess_.poll(pid) if e.errno == errno.ECHILD:
ch.remove(pid)
for f in self._xauthfiles.values(): else:
try: raise
os.unlink(f) if not ch:
except: break
pass time.sleep(0.1)
for pid in ch:
warning("Killing forcefully process %d." % pid)
os.kill(pid, signal.SIGKILL)
for pid in ch:
try:
netns.subprocess_.poll(pid)
except OSError, e:
if e.errno != errno.ECHILD:
raise
finally:
for f in self._xauthfiles.values():
try:
os.unlink(f)
except:
pass
def reply(self, code, text): def reply(self, code, text):
"Send back a reply to the client; handle multiline messages" "Send back a reply to the client; handle multiline messages"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment