When working without a current event base, don't try to use IOCP listeners

This fixes a bug turned up with the http unit tests, where we create
the evhttp object using an implicit (NULL) event_base.  This failed
pretty badly when we tried to use IOCP-based listeners.  We could
hunt for the current base from inside listener.c in the future, or
get the iocp base some other way, but for now this is probably the safest
solution.
This commit is contained in:
Nick Mathewson 2010-02-18 00:27:35 -05:00
parent 32c6f1bacd
commit cb52838fc5

View File

@ -117,7 +117,7 @@ evconnlistener_new(struct event_base *base,
struct evconnlistener_event *lev;
#ifdef WIN32
if (event_base_get_iocp(base)) {
if (base && event_base_get_iocp(base)) {
const struct win32_extension_fns *ext =
event_get_win32_extension_fns();
if (ext->AcceptEx && ext->GetAcceptExSockaddrs)
@ -345,7 +345,7 @@ new_accepting_socket(struct evconnlistener_iocp *lev, int family)
event_deferred_cb_init(&res->deferred,
accepted_socket_invoke_user_cb, res);
InitializeCriticalSection(&res->lock);
InitializeCriticalSectionAndSpinCount(&res->lock, 1000);
return res;
}
@ -558,7 +558,7 @@ evconnlistener_new_async(struct event_base *base,
struct evconnlistener_iocp *lev;
int i;
if (!event_base_get_iocp(base))
if (!base || !event_base_get_iocp(base))
goto err;
/* XXXX duplicate code */
@ -590,7 +590,7 @@ evconnlistener_new_async(struct event_base *base,
if (event_iocp_port_associate(lev->port, fd, 1) < 0)
goto err_free_lev;
InitializeCriticalSection(&lev->lock);
InitializeCriticalSectionAndSpinCount(&lev->lock, 1000);
lev->n_accepting = N_SOCKETS_PER_LISTENER;
lev->accepting = mm_calloc(lev->n_accepting,