From e5e4ee6260e7b98d6c836e681dd253e9ca01c8d1 Mon Sep 17 00:00:00 2001 From: Przemek Zygmunt Date: Wed, 27 Jan 2021 21:34:43 +0100 Subject: [PATCH] When a stream socket peer has performed an orderly shutdown, the return value will be 0 (the traditional end-of-file return). --- src/mqtt_pal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mqtt_pal.c b/src/mqtt_pal.c index 759a0f7..9b9f69f 100644 --- a/src/mqtt_pal.c +++ b/src/mqtt_pal.c @@ -332,7 +332,7 @@ ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t bufsz, int /* successfully read bytes from the socket */ buf += rv; bufsz -= rv; - } else if (rv < 0 && errno != EAGAIN && errno != EWOULDBLOCK) { + } else if (rv == 0 || (rv < 0 && errno != EAGAIN && errno != EWOULDBLOCK)) { /* an error occurred that wasn't "nothing to read". */ return MQTT_ERROR_SOCKET_ERROR; }