Allow evconnlistener to be created in disabled state.

This commit is contained in:
Alexander Drozdov 2011-10-03 08:12:32 +04:00 committed by Nick Mathewson
parent b3bc77b673
commit 9593a33fd1
2 changed files with 5 additions and 1 deletions

View File

@ -69,6 +69,9 @@ typedef void (*evconnlistener_errorcb)(struct evconnlistener *, void *);
/** Flag: Indicates that the listener should be locked so it's safe to use
* from multiple threadcs at once. */
#define LEV_OPT_THREADSAFE (1u<<4)
/** Flag: Indicates that the listener should be created in disabled
* state. Use evconnlistener_enable() to enable it later. */
#define LEV_OPT_DISABLED (1u<<5)
/**
Allocate a new evconnlistener object to listen for incoming TCP connections

View File

@ -193,7 +193,8 @@ evconnlistener_new(struct event_base *base,
event_assign(&lev->listener, base, fd, EV_READ|EV_PERSIST,
listener_read_cb, lev);
evconnlistener_enable(&lev->base);
if (!(flags & LEV_OPT_DISABLED))
evconnlistener_enable(&lev->base);
return &lev->base;
}