Skip to content

Commit 5f3ce9e

Browse files
committed
rename ClientContext::wait_until_sent() to wait_until_acked()
While looking at esp8266#6348 and esp8266#6369, and after checking into lwIP sources, it appears that the tests in ClientContext::wait_until_sent() effectively wait for all acks on current output buffer. Comments are added.
1 parent e3fe7a5 commit 5f3ce9e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

libraries/ESP8266WiFi/src/WiFiClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ bool WiFiClient::flush(unsigned int maxWaitMs)
304304

305305
if (maxWaitMs == 0)
306306
maxWaitMs = WIFICLIENT_MAX_FLUSH_WAIT_MS;
307-
return _client->wait_until_sent(maxWaitMs);
307+
return _client->wait_until_acked(maxWaitMs);
308308
}
309309

310310
bool WiFiClient::stop(unsigned int maxWaitMs)

libraries/ESP8266WiFi/src/include/ClientContext.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class ClientContext
314314
_rx_buf_offset = 0;
315315
}
316316

317-
bool wait_until_sent(int max_wait_ms = WIFICLIENT_MAX_FLUSH_WAIT_MS)
317+
bool wait_until_acked(int max_wait_ms = WIFICLIENT_MAX_FLUSH_WAIT_MS)
318318
{
319319
// https://github.com/esp8266/Arduino/pull/3967#pullrequestreview-83451496
320320
// option 1 done
@@ -351,6 +351,8 @@ class ClientContext
351351
delay(0); // from sys or os context
352352

353353
if ((state() != ESTABLISHED) || (sndbuf == TCP_SND_BUF)) {
354+
// peer has closed or all bytes are sent and acked
355+
// ((TCP_SND_BUF-sndbuf) is the amount of un-acked bytes)
354356
break;
355357
}
356358
}
@@ -484,7 +486,7 @@ class ClientContext
484486
} while(true);
485487

486488
if (_sync)
487-
wait_until_sent();
489+
wait_until_acked();
488490

489491
return _written;
490492
}

0 commit comments

Comments
 (0)