Revision 72cf2d4f aio.c
b/aio.c | ||
---|---|---|
13 | 13 |
|
14 | 14 |
#include "qemu-common.h" |
15 | 15 |
#include "block.h" |
16 |
#include "sys-queue.h"
|
|
16 |
#include "qemu-queue.h"
|
|
17 | 17 |
#include "qemu_socket.h" |
18 | 18 |
|
19 | 19 |
typedef struct AioHandler AioHandler; |
20 | 20 |
|
21 | 21 |
/* The list of registered AIO handlers */ |
22 |
static LIST_HEAD(, AioHandler) aio_handlers; |
|
22 |
static QLIST_HEAD(, AioHandler) aio_handlers;
|
|
23 | 23 |
|
24 | 24 |
/* This is a simple lock used to protect the aio_handlers list. Specifically, |
25 | 25 |
* it's used to ensure that no callbacks are removed while we're walking and |
... | ... | |
35 | 35 |
AioFlushHandler *io_flush; |
36 | 36 |
int deleted; |
37 | 37 |
void *opaque; |
38 |
LIST_ENTRY(AioHandler) node; |
|
38 |
QLIST_ENTRY(AioHandler) node;
|
|
39 | 39 |
}; |
40 | 40 |
|
41 | 41 |
static AioHandler *find_aio_handler(int fd) |
42 | 42 |
{ |
43 | 43 |
AioHandler *node; |
44 | 44 |
|
45 |
LIST_FOREACH(node, &aio_handlers, node) { |
|
45 |
QLIST_FOREACH(node, &aio_handlers, node) {
|
|
46 | 46 |
if (node->fd == fd) |
47 | 47 |
if (!node->deleted) |
48 | 48 |
return node; |
... | ... | |
72 | 72 |
* deleted because deleted nodes are only cleaned up after |
73 | 73 |
* releasing the walking_handlers lock. |
74 | 74 |
*/ |
75 |
LIST_REMOVE(node, node); |
|
75 |
QLIST_REMOVE(node, node);
|
|
76 | 76 |
qemu_free(node); |
77 | 77 |
} |
78 | 78 |
} |
... | ... | |
81 | 81 |
/* Alloc and insert if it's not already there */ |
82 | 82 |
node = qemu_mallocz(sizeof(AioHandler)); |
83 | 83 |
node->fd = fd; |
84 |
LIST_INSERT_HEAD(&aio_handlers, node, node); |
|
84 |
QLIST_INSERT_HEAD(&aio_handlers, node, node);
|
|
85 | 85 |
} |
86 | 86 |
/* Update handler with latest information */ |
87 | 87 |
node->io_read = io_read; |
... | ... | |
109 | 109 |
*/ |
110 | 110 |
qemu_aio_wait(); |
111 | 111 |
|
112 |
LIST_FOREACH(node, &aio_handlers, node) { |
|
112 |
QLIST_FOREACH(node, &aio_handlers, node) {
|
|
113 | 113 |
ret |= node->io_flush(node->opaque); |
114 | 114 |
} |
115 | 115 |
} while (qemu_bh_poll() || ret > 0); |
... | ... | |
133 | 133 |
FD_ZERO(&wrfds); |
134 | 134 |
|
135 | 135 |
/* fill fd sets */ |
136 |
LIST_FOREACH(node, &aio_handlers, node) { |
|
136 |
QLIST_FOREACH(node, &aio_handlers, node) {
|
|
137 | 137 |
/* If there aren't pending AIO operations, don't invoke callbacks. |
138 | 138 |
* Otherwise, if there are no AIO requests, qemu_aio_wait() would |
139 | 139 |
* wait indefinitely. |
... | ... | |
168 | 168 |
|
169 | 169 |
/* we have to walk very carefully in case |
170 | 170 |
* qemu_aio_set_fd_handler is called while we're walking */ |
171 |
node = LIST_FIRST(&aio_handlers); |
|
171 |
node = QLIST_FIRST(&aio_handlers);
|
|
172 | 172 |
while (node) { |
173 | 173 |
AioHandler *tmp; |
174 | 174 |
|
... | ... | |
184 | 184 |
} |
185 | 185 |
|
186 | 186 |
tmp = node; |
187 |
node = LIST_NEXT(node, node); |
|
187 |
node = QLIST_NEXT(node, node);
|
|
188 | 188 |
|
189 | 189 |
if (tmp->deleted) { |
190 |
LIST_REMOVE(tmp, node); |
|
190 |
QLIST_REMOVE(tmp, node);
|
|
191 | 191 |
qemu_free(tmp); |
192 | 192 |
} |
193 | 193 |
} |
Also available in: Unified diff