mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-02 19:15:20 +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 5e62ba3428
)
This commit is contained in:
parent
d13b354bf0
commit
9a7bbc246b
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user