[485143] Fix detection of broken connections on Windows.

Thanks to Pierre-Yves Boisbunon.

Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=485143
pull/145/head
Roger A. Light 10 years ago
parent c7d4f4bcff
commit 00491da031

@ -1,3 +1,6 @@
Broker:
- Fix detection of broken connections on Windows. Closes #485143.
Client library:
- mosq->want_write should be cleared immediately before a call to SSL_write,
to allow clients using mosquitto_want_write() to get accurate results.

@ -56,7 +56,6 @@ extern int run;
extern int g_clients_expired;
#endif
static void loop_handle_errors(struct mosquitto_db *db, struct pollfd *pollfds);
static void loop_handle_reads_writes(struct mosquitto_db *db, struct pollfd *pollfds);
#ifdef WITH_WEBSOCKETS
@ -322,7 +321,7 @@ int mosquitto_main_loop(struct mosquitto_db *db, mosq_sock_t *listensock, int li
fdcount = WSAPoll(pollfds, pollfd_index, 100);
#endif
if(fdcount == -1){
loop_handle_errors(db, pollfds);
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error in poll: %s.", strerror(errno));
}else{
loop_handle_reads_writes(db, pollfds);
@ -437,23 +436,6 @@ void do_disconnect(struct mosquitto_db *db, struct mosquitto *context)
}
}
/* Error ocurred, probably an fd has been closed.
* Loop through and check them all.
*/
static void loop_handle_errors(struct mosquitto_db *db, struct pollfd *pollfds)
{
struct mosquitto *context, *ctxt_tmp;
HASH_ITER(hh_sock, db->contexts_by_sock, context, ctxt_tmp){
if(context->pollfd_index < 0){
continue;
}
if(pollfds[context->pollfd_index].revents & (POLLERR | POLLNVAL)){
do_disconnect(db, context);
}
}
}
static void loop_handle_reads_writes(struct mosquitto_db *db, struct pollfd *pollfds)
{
@ -467,6 +449,10 @@ static void loop_handle_reads_writes(struct mosquitto_db *db, struct pollfd *pol
}
assert(pollfds[context->pollfd_index].fd == context->sock);
if(pollfds[context->pollfd_index].revents & (POLLERR | POLLNVAL)){
do_disconnect(db, context);
continue;
}
#ifdef WITH_TLS
if(pollfds[context->pollfd_index].revents & POLLOUT ||
context->want_write ||

Loading…
Cancel
Save