提交 5e62ba34 编写于 作者: R Royce Lv 提交者: Eric Blake

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: NRoyce Lv <lvroyce@linux.vnet.ibm.com>
上级 5e21da56
...@@ -178,6 +178,7 @@ class virEventLoopPure: ...@@ -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: ...@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册