Commit 701cbfee authored by alina's avatar alina

bugfix: EINTRs caught

parent ed07c351
# vim:ts=4:sw=4:et:ai:sts=4 # vim:ts=4:sw=4:et:ai:sts=4
import os, os.path, socket, subprocess, sys, syslog import errno, os, os.path, socket, subprocess, sys, syslog
from syslog import LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG from syslog import LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG
__all__ = ["ip_path", "tc_path", "brctl_path", "sysctl_path", "hz"] __all__ = ["ip_path", "tc_path", "brctl_path", "sysctl_path", "hz"]
...@@ -133,7 +133,16 @@ def logger(priority, message): ...@@ -133,7 +133,16 @@ def logger(priority, message):
return return
if priority > _log_level: if priority > _log_level:
return return
_log_stream.write("[%d] %s\n" % (os.getpid(), message.rstrip()))
while True:
try:
_log_stream.write("[%d] %s\n" % (os.getpid(), message.rstrip()))
except OSError, e: # pragma: no cover
if e.errno == errno.EINTR:
continue
else:
raise
break
_log_stream.flush() _log_stream.flush()
def error(message): def error(message):
......
#!/usr/bin/env python #!/usr/bin/env python
# vim:ts=4:sw=4:et:ai:sts=4 # vim:ts=4:sw=4:et:ai:sts=4
import os, socket, sys, traceback, unshare, weakref import errno, os, socket, sys, traceback, unshare, weakref
from netns.environ import * from netns.environ import *
import netns.interface, netns.protocol, netns.subprocess_ import netns.interface, netns.protocol, netns.subprocess_
...@@ -61,7 +61,17 @@ class Node(object): ...@@ -61,7 +61,17 @@ class Node(object):
if self._slave: if self._slave:
self._slave.shutdown() self._slave.shutdown()
exitcode = os.waitpid(self._pid, 0)[1]
while True:
try:
exitcode = os.waitpid(self._pid, 0)[1]
except OSError, e: # pragma: no cover
if e.errno == errno.EINTR:
continue
else:
raise
break
if exitcode != 0: if exitcode != 0:
error("Node(0x%x) process %d exited with non-zero status: %d" % error("Node(0x%x) process %d exited with non-zero status: %d" %
(id(self), self._pid, exitcode)) (id(self), self._pid, exitcode))
......
...@@ -158,7 +158,9 @@ class Server(object): ...@@ -158,7 +158,9 @@ class Server(object):
line = self._rfd.readline() line = self._rfd.readline()
except IOError, e: except IOError, e:
line = None line = None
if e.errno != errno.EINTR: if e.errno == errno.EINTR:
continue
else:
raise raise
break break
if not line: if not line:
...@@ -674,7 +676,7 @@ class Client(object): ...@@ -674,7 +676,7 @@ class Client(object):
if code / 100 == 4: if code / 100 == 4:
return None return None
else: else:
raise "Error on command: %d %s" % (code, text) raise RuntimeError("Error on command: %d %s" % (code, text))
def wait(self, pid): def wait(self, pid):
"""Equivalent to Popen.wait(). Waits for the process to finish and """Equivalent to Popen.wait(). Waits for the process to finish and
......
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