From 547ec85b58b709f1a4335321920492ea23a87043 Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov Date: Tue, 8 Dec 2015 12:13:03 +0000 Subject: [PATCH] Properly disable socketpair-related stuff PUBLISHED_FROM=f3a236470281af80848c8f78163980083190c081 --- mongoose.c | 6 +++++- mongoose.h | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mongoose.c b/mongoose.c index 3325418a..fe261c4c 100644 --- a/mongoose.c +++ b/mongoose.c @@ -1925,7 +1925,9 @@ void mg_close_conn(struct mg_connection *conn) { void mg_mgr_init(struct mg_mgr *m, void *user_data) { memset(m, 0, sizeof(*m)); +#ifndef MG_DISABLE_SOCKETPAIR m->ctl[0] = m->ctl[1] = INVALID_SOCKET; +#endif m->user_data = user_data; #ifdef _WIN32 @@ -1989,8 +1991,8 @@ void mg_mgr_free(struct mg_mgr *m) { #ifndef MG_DISABLE_SOCKETPAIR if (m->ctl[0] != INVALID_SOCKET) closesocket(m->ctl[0]); if (m->ctl[1] != INVALID_SOCKET) closesocket(m->ctl[1]); -#endif m->ctl[0] = m->ctl[1] = INVALID_SOCKET; +#endif for (conn = m->active_connections; conn != NULL; conn = tmp_conn) { tmp_conn = conn->next; @@ -3367,7 +3369,9 @@ time_t mg_mgr_poll(struct mg_mgr *mgr, int milli) { FD_ZERO(&read_set); FD_ZERO(&write_set); FD_ZERO(&err_set); +#ifndef MG_DISABLE_SOCKETPAIR mg_add_to_set(mgr->ctl[1], &read_set, &max_fd); +#endif for (nc = mgr->active_connections, num_fds = 0; nc != NULL; nc = tmp) { tmp = nc->next; diff --git a/mongoose.h b/mongoose.h index 7cbabe52..14fae65e 100644 --- a/mongoose.h +++ b/mongoose.h @@ -706,9 +706,11 @@ typedef void (*mg_event_handler_t)(struct mg_connection *, int ev, void *); struct mg_mgr { struct mg_connection *active_connections; const char *hexdump_file; /* Debug hexdump file path */ - sock_t ctl[2]; /* Socketpair for mg_wakeup() */ - void *user_data; /* User data */ - void *mgr_data; /* Implementation-specific event manager's data. */ +#ifndef MG_DISABLE_SOCKETPAIR + sock_t ctl[2]; /* Socketpair for mg_wakeup() */ +#endif + void *user_data; /* User data */ + void *mgr_data; /* Implementation-specific event manager's data. */ #ifdef MG_ENABLE_JAVASCRIPT struct v7 *v7; #endif