diff --git a/user/httpd.c b/user/httpd.c index 8da3f68..97eceeb 100644 --- a/user/httpd.c +++ b/user/httpd.c @@ -395,7 +395,11 @@ static void ICACHE_FLASH_ATTR httpdDisconCb(void *arg) { int i; for (i=0; istate==ESPCONN_NONE || connData[i].conn->state==ESPCONN_CLOSE) { + //Why the >=ESPCONN_CLOSE and not ==? Well, seems the stack sometimes de-allocates + //espconns under our noses, especially when connections are interrupted. The memory + //is then used for something else, and we can use that to capture *most* of the + //disconnect cases. + if (connData[i].conn->state==ESPCONN_NONE || connData[i].conn->state>=ESPCONN_CLOSE) { connData[i].conn=NULL; if (connData[i].cgi!=NULL) connData[i].cgi(&connData[i]); //flush cgi data httpdRetireConn(&connData[i]);