It seems support for GetCompletionEventEx is not in my mingw. Use the simpler interface instead, for now.

svn:r1175
This commit is contained in:
Nick Mathewson 2009-04-16 00:27:32 +00:00
parent 93d4f884aa
commit 09c23b6a56

View File

@ -7,8 +7,6 @@
#include "util-internal.h" #include "util-internal.h"
#include "iocp-internal.h" #include "iocp-internal.h"
#define N_OVERLAPPED_ENTRIES 32
void void
event_overlapped_init(struct event_overlapped *o, iocp_callback cb) event_overlapped_init(struct event_overlapped *o, iocp_callback cb)
{ {
@ -17,30 +15,28 @@ event_overlapped_init(struct event_overlapped *o, iocp_callback cb)
} }
static void static void
handle_entry(OVERLAPPED_ENTRY *ent) handle_entry(OVERLAPPED *o, ULONG_PTR completion_key, DWORD nBytes)
{ {
OVERLAPPED *o = ent->lpOverlapped; OVERLAPPED *o = ent->lpOverlapped;
struct event_overlapped *eo = struct event_overlapped *eo =
EVUTIL_UPCAST(o, struct event_overlapped, overlapped); EVUTIL_UPCAST(o, struct event_overlapped, overlapped);
eo = upcast(o, struct event_overlapped, overlapped); eo = upcast(o, struct event_overlapped, overlapped);
eo->cb(eo, ent->lpCompletionKey, ent->dwNumberOfBytesTransferred); eo->cb(eo, completion_key, nBytes);
} }
static void static void
loop(struct event_iocp_port *port, long ms) loop(struct event_iocp_port *port, long ms)
{ {
OVERLAPPED_ENTRY entries[N_OVERLAPPED_ENTRIES]; OVERLAPPED *overlapped;
ULONG n_entries; ULONG_PTR key;
int i; DWORD bytes;
if (ms <= 0) if (ms <= 0)
ms = INFINITE; ms = INFINITE;
while (GetQueuedCompletionStatusEx(port->port, while(GetQueuedCompletionStatus(port->port, &nBytes, &key,
entries, N_OVERLAPPED_ENTRIES, &n_entries, ms, 1)) { &overlapped, ms)) {
for (i = 0; i < n_entries; ++i) { handle_entry(overlapped, key, bytes);
handle_entry(&entries[i]);
}
} }
} }