Skip to content

Commit

Permalink
Fix repeated "Error in poll" messages on Windows.
Browse files Browse the repository at this point in the history
This occurs when only websockets listeners are defined.

Closes #1391. Thanks to stopak.
  • Loading branch information
ralight committed Sep 11, 2019
1 parent 4dc98c4 commit 9ad5fe7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Expand Up @@ -11,6 +11,8 @@ Broker:
- Fix Will for v5 clients not being sent if will delay interval was greater
than the session expiry interval. Closes #1401.
- Fix CRL file not being reloaded on HUP. Closes #35.
- Fix repeated "Error in poll" messages on Windows when only websockets
listeners are defined. Closes #1391.

Client library:
- Fix reconnect backoff for the situation where connections are dropped rather
Expand Down
13 changes: 12 additions & 1 deletion src/loop.c
Expand Up @@ -532,7 +532,18 @@ int mosquitto_main_loop(struct mosquitto_db *db, mosq_sock_t *listensock, int li
}
#else
if(fdcount == -1){
log__printf(NULL, MOSQ_LOG_ERR, "Error in poll: %s.", strerror(errno));
# ifdef WIN32
if(pollfd_index == 0 && WSAGetLastError() == WSAEINVAL){
/* WSAPoll() immediately returns an error if it is not given
* any sockets to wait on. This can happen if we only have
* websockets listeners. Sleep a little to prevent a busy loop.
*/
Sleep(10);
}else
# endif
{
log__printf(NULL, MOSQ_LOG_ERR, "Error in poll: %s.", strerror(errno));
}
}else{
loop_handle_reads_writes(db, pollfds);

Expand Down

0 comments on commit 9ad5fe7

Please sign in to comment.