Skip to content

Commit

Permalink
Fix undefined behaviour in WiFiServer::setNoDelay (esp8266#1695)
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed Mar 23, 2016
1 parent 2bc6d6b commit 213914e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
13 changes: 3 additions & 10 deletions libraries/ESP8266WiFi/src/WiFiServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,11 @@ void WiFiServer::begin() {
}

void WiFiServer::setNoDelay(bool nodelay) {
if (!_pcb)
return;

if (nodelay)
tcp_nagle_disable(_pcb);
else
tcp_nagle_enable(_pcb);
_noDelay = nodelay;
}

bool WiFiServer::getNoDelay() {
if (!_pcb)
return false;
return tcp_nagle_disabled(_pcb);
return _noDelay;
}

bool WiFiServer::hasClient() {
Expand All @@ -106,6 +98,7 @@ WiFiClient WiFiServer::available(byte* status) {
if (_unclaimed) {
WiFiClient result(_unclaimed);
_unclaimed = _unclaimed->next();
result.setNoDelay(_noDelay);
DEBUGV("WS:av\r\n");
return result;
}
Expand Down
1 change: 1 addition & 0 deletions libraries/ESP8266WiFi/src/WiFiServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class WiFiServer : public Server {

ClientContext* _unclaimed;
ClientContext* _discarded;
bool _noDelay = false;

public:
WiFiServer(IPAddress addr, uint16_t port);
Expand Down

0 comments on commit 213914e

Please sign in to comment.