From 4a08626f43df9d97990a1dffc0725d3490f8a49a Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Mon, 17 May 2021 16:44:03 +0100 Subject: [PATCH] Only a single call to lws_write() is required. --- src/websockets.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/websockets.c b/src/websockets.c index 03dae1c9..cef8377b 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -125,7 +125,6 @@ static int callback_mqtt( { struct mosquitto *mosq = NULL; struct mosquitto__packet *packet; - size_t txlen; int count; unsigned int ucount; const struct lws_protocols *p; @@ -233,12 +232,7 @@ static int callback_mqtt( memmove(&packet->payload[LWS_PRE], packet->payload, packet->packet_length); packet->pos += LWS_PRE; } - if(packet->to_process > WS_TX_BUF_SIZE){ - txlen = WS_TX_BUF_SIZE; - }else{ - txlen = packet->to_process; - } - count = lws_write(wsi, &packet->payload[packet->pos], txlen, LWS_WRITE_BINARY); + count = lws_write(wsi, &packet->payload[packet->pos], packet->to_process, LWS_WRITE_BINARY); if(count < 0){ if (mosq->state == mosq_cs_disconnect_ws || mosq->state == mosq_cs_disconnecting