From e971868f21b41c586401cc0588f58f54ff13590c Mon Sep 17 00:00:00 2001 From: Jeroen Domburg Date: Thu, 11 Dec 2014 22:59:57 +0100 Subject: [PATCH] Working around a stupid error in the esp code... mostly... I hope. --- user/httpd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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]);