Skip to content

Commit 213914e

Browse files
committed
Fix undefined behaviour in WiFiServer::setNoDelay (#1695)
1 parent 2bc6d6b commit 213914e

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

libraries/ESP8266WiFi/src/WiFiServer.cpp

+3-10
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,11 @@ void WiFiServer::begin() {
8181
}
8282

8383
void WiFiServer::setNoDelay(bool nodelay) {
84-
if (!_pcb)
85-
return;
86-
87-
if (nodelay)
88-
tcp_nagle_disable(_pcb);
89-
else
90-
tcp_nagle_enable(_pcb);
84+
_noDelay = nodelay;
9185
}
9286

9387
bool WiFiServer::getNoDelay() {
94-
if (!_pcb)
95-
return false;
96-
return tcp_nagle_disabled(_pcb);
88+
return _noDelay;
9789
}
9890

9991
bool WiFiServer::hasClient() {
@@ -106,6 +98,7 @@ WiFiClient WiFiServer::available(byte* status) {
10698
if (_unclaimed) {
10799
WiFiClient result(_unclaimed);
108100
_unclaimed = _unclaimed->next();
101+
result.setNoDelay(_noDelay);
109102
DEBUGV("WS:av\r\n");
110103
return result;
111104
}

libraries/ESP8266WiFi/src/WiFiServer.h

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class WiFiServer : public Server {
4242

4343
ClientContext* _unclaimed;
4444
ClientContext* _discarded;
45+
bool _noDelay = false;
4546

4647
public:
4748
WiFiServer(IPAddress addr, uint16_t port);

0 commit comments

Comments
 (0)