From 9ea161f90e179faf8162775a405462fd77620023 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sun, 18 May 2014 20:54:44 +0100 Subject: [PATCH] Return success on libwebsocket_write==0. --- src/loop.c | 2 +- src/websockets.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/loop.c b/src/loop.c index 886c8e56..275303ee 100644 --- a/src/loop.c +++ b/src/loop.c @@ -74,7 +74,7 @@ int mosquitto_main_loop(struct mosquitto_db *db, int *listensock, int listensock int rc; #endif #ifdef WITH_WEBSOCKETS - struct libwebsocket_context *ws_context; + struct libwebsocket_context *ws_context = NULL; #endif #ifndef WIN32 diff --git a/src/websockets.c b/src/websockets.c index 2018087c..dc9a033b 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -151,6 +151,9 @@ static int callback_mqtt(struct libwebsocket_context *context, packet->pos += LWS_SEND_BUFFER_PRE_PADDING; } count = libwebsocket_write(wsi, &packet->payload[packet->pos], packet->to_process, LWS_WRITE_BINARY); + if(count < 0){ + return 0; + } packet->to_process -= count; packet->pos += count; if(packet->to_process > 0){