Skip to content

Commit

Permalink
rename ClientContext::wait_until_sent() to wait_until_acked()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
d-a-v committed Feb 27, 2021
1 parent e3fe7a5 commit 5f3ce9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/WiFiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ bool WiFiClient::flush(unsigned int maxWaitMs)

if (maxWaitMs == 0)
maxWaitMs = WIFICLIENT_MAX_FLUSH_WAIT_MS;
return _client->wait_until_sent(maxWaitMs);
return _client->wait_until_acked(maxWaitMs);
}

bool WiFiClient::stop(unsigned int maxWaitMs)
Expand Down
6 changes: 4 additions & 2 deletions libraries/ESP8266WiFi/src/include/ClientContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class ClientContext
_rx_buf_offset = 0;
}

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

if ((state() != ESTABLISHED) || (sndbuf == TCP_SND_BUF)) {
// peer has closed or all bytes are sent and acked
// ((TCP_SND_BUF-sndbuf) is the amount of un-acked bytes)
break;
}
}
Expand Down Expand Up @@ -484,7 +486,7 @@ class ClientContext
} while(true);

if (_sync)
wait_until_sent();
wait_until_acked();

return _written;
}
Expand Down

0 comments on commit 5f3ce9e

Please sign in to comment.