Fix compilation with threading disabled.

svn:r1546
This commit is contained in:
Nick Mathewson 2009-11-18 21:16:33 +00:00
parent d7d1f1da09
commit 767eb70f50
4 changed files with 13 additions and 0 deletions

View File

@ -81,6 +81,10 @@ void event_deferred_cb_cancel(struct deferred_cb_queue *, struct deferred_cb *);
*/ */
void event_deferred_cb_schedule(struct deferred_cb_queue *, struct deferred_cb *); void event_deferred_cb_schedule(struct deferred_cb_queue *, struct deferred_cb *);
#ifdef _EVENT_DISABLE_THREAD_SUPPORT
#define LOCK_DEFERRED_QUEUE(q) (void)0
#define UNLOCK_DEFERRED_QUEUE(q) (void)0
#else
#define LOCK_DEFERRED_QUEUE(q) \ #define LOCK_DEFERRED_QUEUE(q) \
do { \ do { \
if ((q)->lock) \ if ((q)->lock) \
@ -94,6 +98,7 @@ void event_deferred_cb_schedule(struct deferred_cb_queue *, struct deferred_cb *
_evthread_locking_fn(EVTHREAD_UNLOCK|EVTHREAD_WRITE, \ _evthread_locking_fn(EVTHREAD_UNLOCK|EVTHREAD_WRITE, \
(q)->lock); \ (q)->lock); \
} while (0) } while (0)
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -2114,7 +2114,9 @@ evdns_server_request_get_requesting_addr(struct evdns_server_request *_req, stru
static void static void
evdns_request_timeout_callback(evutil_socket_t fd, short events, void *arg) { evdns_request_timeout_callback(evutil_socket_t fd, short events, void *arg) {
struct evdns_request *const req = (struct evdns_request *) arg; struct evdns_request *const req = (struct evdns_request *) arg;
#ifndef _EVENT_DISABLE_THREAD_SUPPORT
struct evdns_base *base = req->base; struct evdns_base *base = req->base;
#endif
(void) fd; (void) fd;
(void) events; (void) events;

View File

@ -347,6 +347,7 @@ event_base_new_with_config(struct event_config *cfg)
base->th_notify_fd[0] = -1; base->th_notify_fd[0] = -1;
base->th_notify_fd[1] = -1; base->th_notify_fd[1] = -1;
#ifndef _EVENT_DISABLE_THREAD_SUPPORT
if (!cfg || !(cfg->flags & EVENT_BASE_FLAG_NOLOCK)) { if (!cfg || !(cfg->flags & EVENT_BASE_FLAG_NOLOCK)) {
int r; int r;
EVTHREAD_ALLOC_LOCK(base->th_base_lock); EVTHREAD_ALLOC_LOCK(base->th_base_lock);
@ -358,6 +359,7 @@ event_base_new_with_config(struct event_config *cfg)
return NULL; return NULL;
} }
} }
#endif
#ifdef WIN32 #ifdef WIN32
if (cfg && (cfg->flags & EVENT_BASE_FLAG_STARTUP_IOCP)) if (cfg && (cfg->flags & EVENT_BASE_FLAG_STARTUP_IOCP))

4
poll.c
View File

@ -125,6 +125,7 @@ poll_dispatch(struct event_base *base, struct timeval *tv)
nfds = pop->nfds; nfds = pop->nfds;
#ifndef _EVENT_DISABLE_THREAD_SUPPORT
if (base->th_base_lock) { if (base->th_base_lock) {
/* If we're using this backend in a multithreaded setting, /* If we're using this backend in a multithreaded setting,
* then we need to work on a copy of event_set, so that we can * then we need to work on a copy of event_set, so that we can
@ -147,6 +148,9 @@ poll_dispatch(struct event_base *base, struct timeval *tv)
} else { } else {
event_set = pop->event_set; event_set = pop->event_set;
} }
#else
event_set = pop->event_set;
#endif
if (tv != NULL) if (tv != NULL)
msec = tv->tv_sec * 1000 + (tv->tv_usec + 999) / 1000; msec = tv->tv_sec * 1000 + (tv->tv_usec + 999) / 1000;