Properly disable socketpair-related stuff

PUBLISHED_FROM=f3a236470281af80848c8f78163980083190c081
This commit is contained in:
Deomid Ryabkov 2015-12-08 12:13:03 +00:00 committed by rojer
parent 845d751e87
commit 547ec85b58
2 changed files with 10 additions and 4 deletions

View File

@ -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;

View File

@ -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