From 9968e35981a2dae93806369f1aa8b737978e84bc Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 9 Dec 2020 11:39:53 +0000 Subject: [PATCH] Fix websockets connections on Windows blocking subsequent connections. Closes #1934. Thanks to sectokia. --- ChangeLog.txt | 4 ++++ src/mux_poll.c | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 158f19c181..4fdcfde542 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +Broker: +- Fix websockets connections on Windows blocking subsequent connections. + Closes #1934. + Build: - Fix cjson include paths. - Fix build using WITH_TLS=no when the openssl headers aren't available. diff --git a/src/mux_poll.c b/src/mux_poll.c index 48ccd7946c..a31e9453ea 100644 --- a/src/mux_poll.c +++ b/src/mux_poll.c @@ -89,7 +89,10 @@ int mux_poll__init(struct mosquitto__listener_sock *listensock, int listensock_c log__printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory."); return MOSQ_ERR_NOMEM; } - memset(pollfds, -1, sizeof(struct pollfd)*pollfd_max); + memset(pollfds, 0, sizeof(struct pollfd)*pollfd_max); + for(i=0; ipollfd_index].revents = 0; }else{ for(i=0; isock; pollfds[i].events = POLLIN | POLLOUT; pollfds[i].revents = 0; @@ -142,7 +145,7 @@ int mux_poll__add_in(struct mosquitto *context) pollfds[context->pollfd_index].revents = 0; }else{ for(i=0; isock; pollfds[i].events = POLLIN; pollfds[i].revents = 0; @@ -158,7 +161,7 @@ int mux_poll__add_in(struct mosquitto *context) int mux_poll__delete(struct mosquitto *context) { if(context->pollfd_index != -1){ - pollfds[context->pollfd_index].fd = -1; + pollfds[context->pollfd_index].fd = INVALID_SOCKET; pollfds[context->pollfd_index].events = 0; pollfds[context->pollfd_index].revents = 0; context->pollfd_index = -1;