Web: prevent redirect server socket exhaustion from stale connections
The HTTP redirect server has max_open_sockets = 2. A client that connects and then disappears silently (network drop, browser crash, mobile radio loss) leaves its socket occupying a slot indefinitely — the server has no way to detect the loss until it tries to write to the socket again. Enable lru_purge_enable on the redirect server so that when both slots are occupied by such stale connections, the least-recently-used one is evicted automatically to make room for a new incoming connection, rather than refusing it outright. Add a "Connection: close" header to the 302 response as a complementary measure. For well-behaved clients this triggers an immediate TCP teardown after the redirect is received, shrinking the window during which a connection can turn into a zombie. Together the two changes provide defence in depth: "Connection: close" prevents stale connections from forming in the first place; lru_purge_enable cleans them up when they do.
Этот коммит содержится в:
@@ -2617,6 +2617,7 @@ bool WebPanelServer::start() {
|
||||
redirect_config.backlog_conn = 0;
|
||||
redirect_config.recv_wait_timeout = 10;
|
||||
redirect_config.send_wait_timeout = 10;
|
||||
redirect_config.httpd.lru_purge_enable = true;
|
||||
redirect_config.stack_size = kWebServerStackSize;
|
||||
redirect_config.task_priority = tskIDLE_PRIORITY + 2;
|
||||
redirect_config.core_id = 0;
|
||||
@@ -2697,6 +2698,7 @@ esp_err_t WebPanelServer::handleHttpRedirect(httpd_req_t* req) {
|
||||
httpd_resp_set_status(req, "302 Found");
|
||||
httpd_resp_set_hdr(req, "Location", location);
|
||||
httpd_resp_set_hdr(req, "Cache-Control", "no-store");
|
||||
httpd_resp_set_hdr(req, "Connection", "close");
|
||||
return httpd_resp_send(req, "", 0);
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user