From 63694392ea096f5c421cb65cd2a8bb9146c5d872 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Wed, 31 Jan 2018 11:26:21 +0100 Subject: [PATCH] ClientContext:_write_some: release buffer once data really accepted for sending may fix #1872 --- libraries/ESP8266WiFi/src/include/ClientContext.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/ESP8266WiFi/src/include/ClientContext.h b/libraries/ESP8266WiFi/src/include/ClientContext.h index 43e9040a48..d53b453942 100644 --- a/libraries/ESP8266WiFi/src/include/ClientContext.h +++ b/libraries/ESP8266WiFi/src/include/ClientContext.h @@ -447,11 +447,13 @@ class ClientContext } err_t err = tcp_write(_pcb, buf, next_chunk, TCP_WRITE_FLAG_COPY); DEBUGV(":wrc %d %d %d\r\n", next_chunk, will_send, (int) err); - _datasource->release_buffer(buf, next_chunk); if (err == ERR_OK) { + _datasource->release_buffer(buf, next_chunk); _written += next_chunk; need_output = true; } else { + // ERR_MEM(-1) is a valid error meaning + // "come back later". It leaves state() opened break; } will_send -= next_chunk;