mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-20 03:25:18 +00:00
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> (cherry picked from commit 5e62ba3428b377d47f5ddbee705ee33027354824)
This commit is contained in:
parent
d13b354bf0
commit
9a7bbc246b
@ -178,6 +178,7 @@ class virEventLoopPure:
|
|||||||
def run_once(self):
|
def run_once(self):
|
||||||
sleep = -1
|
sleep = -1
|
||||||
self.runningPoll = True
|
self.runningPoll = True
|
||||||
|
try:
|
||||||
next = self.next_timeout()
|
next = self.next_timeout()
|
||||||
debug("Next timeout due at %d" % next)
|
debug("Next timeout due at %d" % next)
|
||||||
if next > 0:
|
if next > 0:
|
||||||
@ -212,13 +213,17 @@ class virEventLoopPure:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
want = t.get_last_fired() + interval
|
want = t.get_last_fired() + interval
|
||||||
# Deduct 20ms, since schedular timeslice
|
# Deduct 20ms, since scheduler timeslice
|
||||||
# means we could be ever so slightly early
|
# means we could be ever so slightly early
|
||||||
if now >= (want-20):
|
if now >= (want-20):
|
||||||
debug("Dispatch timer %d now %s want %s" % (t.get_id(), str(now), str(want)))
|
debug("Dispatch timer %d now %s want %s" % (t.get_id(), str(now), str(want)))
|
||||||
t.set_last_fired(now)
|
t.set_last_fired(now)
|
||||||
t.dispatch()
|
t.dispatch()
|
||||||
|
|
||||||
|
except (os.error, select.error), e:
|
||||||
|
if e.args[0] != errno.EINTR:
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
self.runningPoll = False
|
self.runningPoll = False
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user