summaryrefslogtreecommitdiff
path: root/event_iocp.c
diff options
context:
space:
mode:
authorChristopher Davis <chrisd@torproject.org>2010-08-28 02:08:27 -0700
committerChristopher Davis <chrisd@torproject.org>2010-09-08 01:22:21 -0700
commitd844242f9b138be4896942ded25d74a91bf29901 (patch)
tree5edb40d6cb73b0638802e961c0265ba3be1532e1 /event_iocp.c
parent03afa209de96d67f1a4b935460aeabe63f5ef24f (diff)
downloadlibevent-d844242f9b138be4896942ded25d74a91bf29901.tar.gz
Stop IOCP when freeing the event_base.
Diffstat (limited to 'event_iocp.c')
-rw-r--r--event_iocp.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/event_iocp.c b/event_iocp.c
index fe9ea571..82fa9aee 100644
--- a/event_iocp.c
+++ b/event_iocp.c
@@ -73,7 +73,8 @@ loop(void *_port)
EnterCriticalSection(&port->lock);
if (port->shutdown) {
if (--port->n_live_threads == 0)
- ReleaseSemaphore(port->shutdownSemaphore, 1, NULL);
+ ReleaseSemaphore(port->shutdownSemaphore, 1,
+ NULL);
LeaveCriticalSection(&port->lock);
return;
}
@@ -233,13 +234,18 @@ event_iocp_notify_all(struct event_iocp_port *port)
int
event_iocp_shutdown(struct event_iocp_port *port, long waitMsec)
{
+ DWORD ms = INFINITE;
int n;
+
EnterCriticalSection(&port->lock);
port->shutdown = 1;
LeaveCriticalSection(&port->lock);
event_iocp_notify_all(port);
- WaitForSingleObject(port->shutdownSemaphore, waitMsec);
+ if (waitMsec >= 0)
+ ms = waitMsec;
+
+ WaitForSingleObject(port->shutdownSemaphore, ms);
EnterCriticalSection(&port->lock);
n = port->n_live_threads;
LeaveCriticalSection(&port->lock);