mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
ESP8266WebServer - Drop inactive connection when another is waiting to improve page load time (#8216)
* ESP8266WebServer - drop current HC_WAIT_READ connection sooner when another has data Safari sometimes opens two connections when loading a page and only sends a request over the second one, resulting in a 5 second wait (HTTP_MAX_DATA_WAIT) before the request is processed. This commit drops the current connection after 30ms (HTTP_MAX_DATA_AVAILABLE_WAIT) when there is a new connection with data available or the buffer of pending TCP clients is full (currently 5).
This commit is contained in:
@ -99,7 +99,7 @@ void WiFiServer::begin ()
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = htons(mockport);
|
||||
server.sin_addr.s_addr = htonl(global_source_address);
|
||||
if (bind(sock, (struct sockaddr*)&server, sizeof(server)) == -1)
|
||||
@ -150,3 +150,23 @@ void WiFiServer::stop ()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
size_t WiFiServer::hasClientData ()
|
||||
{
|
||||
// Trivial Mocking:
|
||||
// There is no waiting list of clients in this trivial mocking code,
|
||||
// so the code has to act as if the tcp backlog list is full,
|
||||
// and nothing is known about potential further clients.
|
||||
// It could be implemented by accepting new clients and store their data until the current one is closed.
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool WiFiServer::hasMaxPendingClients ()
|
||||
{
|
||||
// Mocking code does not consider the waiting client list,
|
||||
// so it will return ::hasClient() here meaning:
|
||||
// - our waiting client list does not exist
|
||||
// - we consider pending number is max if a new client is waiting
|
||||
// or not max if there's no new client.
|
||||
return hasClient();
|
||||
}
|
||||
|
Reference in New Issue
Block a user