]> git.pld-linux.org Git - packages/qemu.git/blame - qemu-0.9.0-remove-iohandlers.patch
- added patch to fix crash when using qemu with NICs connected via socket
[packages/qemu.git] / qemu-0.9.0-remove-iohandlers.patch
CommitLineData
5b888e18 1diff -Naur qemu-0.9.0.orig/vl.c qemu-0.9.0/vl.c
2--- qemu-0.9.0.orig/vl.c 2007-04-18 19:31:13.000000000 +0200
3+++ qemu-0.9.0/vl.c 2007-04-18 19:32:03.000000000 +0200
4@@ -4140,6 +4140,7 @@
5 IOCanRWHandler *fd_read_poll;
6 IOHandler *fd_read;
7 IOHandler *fd_write;
8+ int deleted;
9 void *opaque;
10 /* temporary data */
11 struct pollfd *ufd;
12@@ -4165,8 +4166,7 @@
13 if (ioh == NULL)
14 break;
15 if (ioh->fd == fd) {
16- *pioh = ioh->next;
17- qemu_free(ioh);
18+ ioh->deleted = 1;
19 break;
20 }
21 pioh = &ioh->next;
22@@ -4187,6 +4187,7 @@
23 ioh->fd_read = fd_read;
24 ioh->fd_write = fd_write;
25 ioh->opaque = opaque;
26+ ioh->deleted = 0;
27 }
28 return 0;
29 }
30@@ -5835,7 +5836,7 @@
31
32 void main_loop_wait(int timeout)
33 {
34- IOHandlerRecord *ioh, *ioh_next;
35+ IOHandlerRecord *ioh;
36 fd_set rfds, wfds, xfds;
37 int ret, nfds;
38 struct timeval tv;
39@@ -5870,6 +5871,8 @@
40 FD_ZERO(&wfds);
41 FD_ZERO(&xfds);
42 for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) {
43+ if (ioh->deleted)
44+ continue;
45 if (ioh->fd_read &&
46 (!ioh->fd_read_poll ||
47 ioh->fd_read_poll(ioh->opaque) != 0)) {
48@@ -5897,9 +5900,11 @@
49 #endif
50 ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv);
51 if (ret > 0) {
52- /* XXX: better handling of removal */
53- for(ioh = first_io_handler; ioh != NULL; ioh = ioh_next) {
54- ioh_next = ioh->next;
55+ IOHandlerRecord **pioh;
56+
57+ for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) {
58+ if (ioh->deleted)
59+ continue;
60 if (FD_ISSET(ioh->fd, &rfds)) {
61 ioh->fd_read(ioh->opaque);
62 }
63@@ -5907,6 +5912,17 @@
64 ioh->fd_write(ioh->opaque);
65 }
66 }
67+
68+ /* remove deleted IO handlers */
69+ pioh = &first_io_handler;
70+ while (*pioh) {
71+ ioh = *pioh;
72+ if (ioh->deleted) {
73+ *pioh = ioh->next;
74+ qemu_free(ioh);
75+ } else
76+ pioh = &ioh->next;
77+ }
78 }
79 #if defined(CONFIG_SLIRP)
80 if (slirp_inited) {
This page took 0.042828 seconds and 4 git commands to generate.