Fix unintended socket close on systems with valid fd=0 descriptor numbering

This commit is contained in:
Sergio R. Caprile 2022-10-19 11:56:03 -03:00
parent 4271aa5b1f
commit 51c51d49ad
2 changed files with 2 additions and 0 deletions

View File

@ -3432,6 +3432,7 @@ struct mg_connection *mg_connect(struct mg_mgr *mgr, const char *url,
} else {
LIST_ADD_HEAD(struct mg_connection, &mgr->conns, c);
c->is_udp = (strncmp(url, "udp:", 4) == 0);
c->fd = (void *) (size_t) -1; // Set to INVALID_SOCKET
c->fn = fn;
c->is_client = true;
c->fn_data = fn_data;

View File

@ -174,6 +174,7 @@ struct mg_connection *mg_connect(struct mg_mgr *mgr, const char *url,
} else {
LIST_ADD_HEAD(struct mg_connection, &mgr->conns, c);
c->is_udp = (strncmp(url, "udp:", 4) == 0);
c->fd = (void *) (size_t) -1; // Set to INVALID_SOCKET
c->fn = fn;
c->is_client = true;
c->fn_data = fn_data;