Skip to content

Commit 1617447

Browse files
committed
fix(websocket): Fixed Tx functions with DYNAMIC_BUFFER
1 parent a363bee commit 1617447

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

components/esp_websocket_client/esp_websocket_client.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -550,9 +550,13 @@ static int esp_websocket_client_send_with_exact_opcode(esp_websocket_client_hand
550550
int ret = -1;
551551
int need_write = len;
552552
int wlen = 0, widx = 0;
553-
554553
bool contained_fin = opcode & WS_TRANSPORT_OPCODES_FIN;
555554

555+
if (esp_websocket_new_buf(client, true) != ESP_OK) {
556+
ESP_LOGE(TAG, "Failed to setup tx buffer");
557+
return -1;
558+
}
559+
556560
while (widx < len || opcode) { // allow for sending "current_opcode" only message with len==0
557561
if (need_write > client->buffer_size) {
558562
need_write = client->buffer_size;
@@ -1226,11 +1230,7 @@ int esp_websocket_client_send_with_opcode(esp_websocket_client_handle_t client,
12261230
ret = ESP_FAIL;
12271231
goto unlock_and_return;
12281232
}
1229-
if (esp_websocket_new_buf(client, true) != ESP_OK) {
1230-
ESP_LOGE(TAG, "Failed to setup tx buffer");
1231-
ret = ESP_FAIL;
1232-
goto unlock_and_return;
1233-
}
1233+
12341234
ret = esp_websocket_client_send_with_exact_opcode(client, opcode | WS_TRANSPORT_OPCODES_FIN, data, len, timeout);
12351235
if (ret < 0) {
12361236
ESP_LOGE(TAG, "Failed to send the buffer");

0 commit comments

Comments
 (0)