Skip to content

Commit

Permalink
Fix websockets connections blocking non-ws connections on Windows.
Browse files Browse the repository at this point in the history
  Closes #1934. Thanks to sectokia and jarapa9.
  • Loading branch information
ralight committed Dec 22, 2020
1 parent ce30f81 commit 97d9f47
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Expand Up @@ -6,6 +6,8 @@ Broker:
- Fix dynamic security configuration possibly not being reloaded on Windows
only. Closes #1962.
- Add more log messages for dynsec load/save error conditions.
- Fix websockets connections blocking non-websockets connections on Windows.
Closes #1934.

Build:
- Fix man pages not being built when using CMake. Closes #1969.
Expand Down
6 changes: 3 additions & 3 deletions src/mux_poll.c
Expand Up @@ -84,7 +84,7 @@ int mux_poll__init(struct mosquitto__listener_sock *listensock, int listensock_c
pollfd_max = (size_t)sysconf(_SC_OPEN_MAX);
#endif

pollfds = mosquitto__malloc(sizeof(struct pollfd)*pollfd_max);
pollfds = mosquitto__calloc(pollfd_max, sizeof(struct pollfd));
if(!pollfds){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
return MOSQ_ERR_NOMEM;
Expand Down Expand Up @@ -145,7 +145,7 @@ int mux_poll__add_in(struct mosquitto *context)

if(context->pollfd_index != -1){
pollfds[context->pollfd_index].fd = context->sock;
pollfds[context->pollfd_index].events = POLLIN | POLLPRI;
pollfds[context->pollfd_index].events = POLLIN;
pollfds[context->pollfd_index].revents = 0;
}else{
for(i=0; i<pollfd_max; i++){
Expand Down Expand Up @@ -230,7 +230,7 @@ int mux_poll__handle(struct mosquitto__listener_sock *listensock, int listensock
loop_handle_reads_writes(pollfds);

for(i=0; i<listensock_count; i++){
if(pollfds[i].revents & (POLLIN | POLLPRI)){
if(pollfds[i].revents & POLLIN){
#ifdef WITH_WEBSOCKETS
if(listensock[i].listener->ws_context){
/* Nothing needs to happen here, because we always call lws_service in the loop.
Expand Down
3 changes: 0 additions & 3 deletions src/websockets.c
Expand Up @@ -188,9 +188,6 @@ static int callback_mqtt(
if(mosq->sock != INVALID_SOCKET){
HASH_DELETE(hh_sock, db.contexts_by_sock, mosq);
mosq->sock = INVALID_SOCKET;
#ifndef WITH_EPOLL
mosq->pollfd_index = -1;
#endif
mux__delete(mosq);
}
mosq->wsi = NULL;
Expand Down

0 comments on commit 97d9f47

Please sign in to comment.