From c78678607d3f31ecc5305c37a3f19be40f9c031e Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Mon, 19 Jun 2017 21:40:19 +0100 Subject: [PATCH] [427] Fix large retained messages over websockets. Thanks to Brian Block. Bug: https://github.com/eclipse/mosquitto/issues/427 --- ChangeLog.txt | 1 + src/websockets.c | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 9272af78..3e1691be 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,7 @@ Broker: - Fix for poor websockets performance. - Fix lazy bridges not timing out for idle_timeout. Closes #417. +- Fix problems with large retained messages over websockets. Closes #427. Clients: - Don't use / in auto-generated client ids. diff --git a/src/websockets.c b/src/websockets.c index 84e5089b..9923a287 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -231,6 +231,7 @@ static int callback_mqtt(struct libwebsocket_context *context, if(mosq->sock > 0){ HASH_DELETE(hh_sock, db->contexts_by_sock, mosq); mosq->sock = INVALID_SOCKET; + mosq->pollfd_index = -1; } mosq->wsi = NULL; do_disconnect(db, mosq); @@ -256,7 +257,7 @@ static int callback_mqtt(struct libwebsocket_context *context, } } - while(mosq->current_out_packet && !lws_send_pipe_choked(mosq->wsi)){ + if(mosq->current_out_packet && !lws_send_pipe_choked(mosq->wsi)){ packet = mosq->current_out_packet; if(packet->pos == 0 && packet->to_process == packet->packet_length){ @@ -296,10 +297,6 @@ static int callback_mqtt(struct libwebsocket_context *context, _mosquitto_free(packet); mosq->next_msg_out = mosquitto_time() + mosq->keepalive; - - if(mosq->current_out_packet){ - libwebsocket_callback_on_writable(mosq->ws_context, mosq->wsi); - } } if(mosq->current_out_packet){ libwebsocket_callback_on_writable(mosq->ws_context, mosq->wsi);