|
|
|
@ -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 ||
|
|
|
|
|