提交 89563efc 编写于 作者: D Daniel P. Berrange

Avoid bogus I/O event errors when closing the QEMU monitor

After calling qemuMonitorClose(), it is still possible for
the QEMU monitor I/O event callback to get invoked. This
will trigger an error message because mon->fd has been set
to -1 at this point. Silently ignore the case where mon->fd
is -1, likewise for mon->watch being zero.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 8e122c2c
......@@ -538,6 +538,9 @@ static void qemuMonitorUpdateWatch(qemuMonitorPtr mon)
VIR_EVENT_HANDLE_HANGUP |
VIR_EVENT_HANDLE_ERROR;
if (!mon->watch)
return;
if (mon->lastError.code == VIR_ERR_OK) {
events |= VIR_EVENT_HANDLE_READABLE;
......@@ -563,6 +566,11 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque) {
#if DEBUG_IO
VIR_DEBUG("Monitor %p I/O on watch %d fd %d events %d", mon, watch, fd, events);
#endif
if (mon->fd == -1 || mon->watch == 0) {
qemuMonitorUnlock(mon);
virObjectUnref(mon);
return;
}
if (mon->fd != fd || mon->watch != watch) {
if (events & (VIR_EVENT_HANDLE_HANGUP | VIR_EVENT_HANDLE_ERROR))
......@@ -830,8 +838,10 @@ void qemuMonitorClose(qemuMonitorPtr mon)
"mon=%p refs=%d", mon, mon->object.refs);
if (mon->fd >= 0) {
if (mon->watch)
if (mon->watch) {
virEventRemoveHandle(mon->watch);
mon->watch = 0;
}
VIR_FORCE_CLOSE(mon->fd);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册