adding handling EINTR to poll to make it more robust

some system call and signal will interrupt poll,
making event loop stops and fails to react events and keepalive message
from libvirt.
adding handling EINTR to poll to make it more robust

Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com>
This commit is contained in:
Royce Lv 2012-07-19 09:49:41 +08:00 committed by Eric Blake
parent 5e21da5630
commit 5e62ba3428

View File

@ -178,6 +178,7 @@ class virEventLoopPure:
def run_once(self):
sleep = -1
self.runningPoll = True
try:
next = self.next_timeout()
debug("Next timeout due at %d" % next)
if next > 0:
@ -212,13 +213,17 @@ class virEventLoopPure:
continue
want = t.get_last_fired() + interval
# Deduct 20ms, since schedular timeslice
# Deduct 20ms, since scheduler timeslice
# means we could be ever so slightly early
if now >= (want-20):
debug("Dispatch timer %d now %s want %s" % (t.get_id(), str(now), str(want)))
t.set_last_fired(now)
t.dispatch()
except (os.error, select.error), e:
if e.args[0] != errno.EINTR:
raise
finally:
self.runningPoll = False