Skip to content

Commit 3b1e8ea

Browse files
authored
rename ClientContext::wait_until_sent() to wait_until_acked() (#7896)
* rename ClientContext::wait_until_sent() to wait_until_acked() While looking at #6348 and #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. * host tests counterpart
1 parent 0894b51 commit 3b1e8ea

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

Diff for: libraries/ESP8266WiFi/src/WiFiClient.cpp

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

309309
if (maxWaitMs == 0)
310310
maxWaitMs = WIFICLIENT_MAX_FLUSH_WAIT_MS;
311-
return _client->wait_until_sent(maxWaitMs);
311+
return _client->wait_until_acked(maxWaitMs);
312312
}
313313

314314
bool WiFiClient::stop(unsigned int maxWaitMs)

Diff for: libraries/ESP8266WiFi/src/include/ClientContext.h

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

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

354354
if ((state() != ESTABLISHED) || (sndbuf == TCP_SND_BUF)) {
355+
// peer has closed or all bytes are sent and acked
356+
// ((TCP_SND_BUF-sndbuf) is the amount of un-acked bytes)
355357
break;
356358
}
357359
}
@@ -508,7 +510,7 @@ class ClientContext
508510
} while(true);
509511

510512
if (_sync)
511-
wait_until_sent();
513+
wait_until_acked();
512514

513515
return _written;
514516
}

Diff for: tests/host/common/include/ClientContext.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class ClientContext
211211
mockverbose("TODO: ClientContext::discard_received()\n");
212212
}
213213

214-
bool wait_until_sent(int max_wait_ms = WIFICLIENT_MAX_FLUSH_WAIT_MS)
214+
bool wait_until_acked(int max_wait_ms = WIFICLIENT_MAX_FLUSH_WAIT_MS)
215215
{
216216
(void)max_wait_ms;
217217
return true;

0 commit comments

Comments
 (0)