From eff8fab1b4175c9fbd75ebbcee020d9de66f91d7 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sun, 4 Nov 2018 22:26:59 +0000 Subject: [PATCH] Only process network errors for clients that have nothing to read. Closes #7. --- ChangeLog.txt | 6 ++++++ src/loop.c | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index bfb4a856..1dfe7edf 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,12 @@ 1.5.4 - 201810xx ================ +Broker: +- Process all pending messages even when a client has disconnected. This means + a client that send a PUBLISH then DISCONNECT quickly, then disconnects will + have its DISCONNECT message processed properly and so no Will will be sent. + Closes #7. + Library: - Fix memory leak that occurred if mosquitto_reconnect() was used when TLS errors were present. Closes #592. diff --git a/src/loop.c b/src/loop.c index 002fb24f..c0de5433 100644 --- a/src/loop.c +++ b/src/loop.c @@ -813,14 +813,15 @@ static void loop_handle_reads_writes(struct mosquitto_db *db, struct pollfd *pol continue; } }while(SSL_DATA_PENDING(context)); - } + }else{ #ifdef WITH_EPOLL - if(events & (EPOLLERR | EPOLLHUP)){ + if(events & (EPOLLERR | EPOLLHUP)){ #else - if(context->pollfd_index >= 0 && pollfds[context->pollfd_index].revents & (POLLERR | POLLNVAL | POLLHUP)){ + if(context->pollfd_index >= 0 && pollfds[context->pollfd_index].revents & (POLLERR | POLLNVAL | POLLHUP)){ #endif - do_disconnect(db, context); - continue; + do_disconnect(db, context); + continue; + } } } }