[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/2] vl.c: set NULL upon deleting handlers in qemu_s
From: |
Corentin Chary |
Subject: |
[Qemu-devel] [PATCH 1/2] vl.c: set NULL upon deleting handlers in qemu_set_fd_handler2() |
Date: |
Tue, 25 Jan 2011 09:33:26 +0100 |
From: Yoshiaki Tamura <address@hidden>
Currently qemu_set_fd_handler2() is only setting ioh->deleted upon
deleting. This may cause a crash when a read handler calls
qemu_set_fd_handler2() to delete handlers, but a write handler is
still invoked from main_loop_wait(). Because main_loop_wait() checks
handlers before calling, setting NULL upon deleting will protect
handlers being called if already deleted.
One example is the new threaded vnc server. When an error occurs in
the context of a read handler, it'll releases resources and deletes
handlers. However, because the write handler still exists, it'll be
called, and then crashes because of lack of resources. This patch
fixes it.
Signed-off-by: Yoshiaki Tamura <address@hidden>
Reviewed-by: Corentin Chary <address@hidden>
---
vl.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/vl.c b/vl.c
index 14255c4..7a26bea 100644
--- a/vl.c
+++ b/vl.c
@@ -1037,6 +1037,8 @@ int qemu_set_fd_handler2(int fd,
QLIST_FOREACH(ioh, &io_handlers, next) {
if (ioh->fd == fd) {
ioh->deleted = 1;
+ ioh->fd_read = NULL;
+ ioh->fd_write = NULL;
break;
}
}
--
1.7.3.4
[Qemu-devel] [PATCH 3/7] Add support for glib based threading and convert qemu thread to use it, Anthony Liguori, 2011/01/24
[Qemu-devel] [PATCH 7/7] Rename QemuThread to QemuSThread to indicate that it is not a generic thread, Anthony Liguori, 2011/01/24
[Qemu-devel] [PATCH 6/7] Teach vnc server to use GThread directly, Anthony Liguori, 2011/01/24