diff --git a/serial/console.c b/serial/console.c index 7b22b36..d38e73a 100644 --- a/serial/console.c +++ b/serial/console.c @@ -49,6 +49,7 @@ console_write_char(char c) { int ICACHE_FLASH_ATTR ajaxConsoleReset(HttpdConnData *connData) { + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. jsonHeader(connData, 200); console_rd = console_wr = console_pos = 0; serbridgeReset(); @@ -57,6 +58,7 @@ ajaxConsoleReset(HttpdConnData *connData) { int ICACHE_FLASH_ATTR ajaxConsoleBaud(HttpdConnData *connData) { + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. char buff[512]; int len, status = 400; len = httpdFindArg(connData->getArgs, "rate", buff, sizeof(buff)); @@ -79,6 +81,7 @@ ajaxConsoleBaud(HttpdConnData *connData) { int ICACHE_FLASH_ATTR ajaxConsole(HttpdConnData *connData) { + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. char buff[2048]; int len; // length of text in buff int console_len = (console_wr+BUF_MAX-console_rd) % BUF_MAX; // num chars in console_buf diff --git a/user/cgi.c b/user/cgi.c index f0d19ac..8f87d38 100644 --- a/user/cgi.c +++ b/user/cgi.c @@ -55,6 +55,7 @@ int ICACHE_FLASH_ATTR printGlobalInfo(char *buff, int buflen, char *token) { extern char *esp_link_version; // in user_main.c int ICACHE_FLASH_ATTR cgiMenu(HttpdConnData *connData) { + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. char buff[1024]; // don't use jsonHeader so the response does get cached httpdStartResponse(connData, 200); diff --git a/user/cgiflash.c b/user/cgiflash.c index 65bfd21..f09beb2 100644 --- a/user/cgiflash.c +++ b/user/cgiflash.c @@ -55,10 +55,7 @@ int ICACHE_FLASH_ATTR cgiReadFlash(HttpdConnData *connData) { //===== Cgi to query which firmware needs to be uploaded next int ICACHE_FLASH_ATTR cgiGetFirmwareNext(HttpdConnData *connData) { - if (connData->conn==NULL) { - //Connection aborted. Clean up. - return HTTPD_CGI_DONE; - } + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. uint8 id = system_upgrade_userbin_check(); httpdStartResponse(connData, 200); @@ -74,10 +71,7 @@ int ICACHE_FLASH_ATTR cgiGetFirmwareNext(HttpdConnData *connData) { //===== Cgi that allows the firmware to be replaced via http POST int ICACHE_FLASH_ATTR cgiUploadFirmware(HttpdConnData *connData) { - if (connData->conn==NULL) { - //Connection aborted. Clean up. - return HTTPD_CGI_DONE; - } + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. int offset = connData->post->received - connData->post->buffLen; if (offset == 0) { @@ -147,10 +141,7 @@ static ETSTimer flash_reboot_timer; // Handle request to reboot into the new firmware int ICACHE_FLASH_ATTR cgiRebootFirmware(HttpdConnData *connData) { - if (connData->conn==NULL) { - //Connection aborted. Clean up. - return HTTPD_CGI_DONE; - } + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. // sanity-check that the 'next' partition actually contains something that looks like // valid firmware diff --git a/user/cgipins.c b/user/cgipins.c index cfee33f..ae6b26c 100644 --- a/user/cgipins.c +++ b/user/cgipins.c @@ -106,6 +106,7 @@ int ICACHE_FLASH_ATTR cgiPinsSet(HttpdConnData *connData) { } int ICACHE_FLASH_ATTR cgiPins(HttpdConnData *connData) { + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. if (connData->requestType == HTTPD_METHOD_GET) { return cgiPinsGet(connData); } else if (connData->requestType == HTTPD_METHOD_POST) { diff --git a/user/cgiwifi.c b/user/cgiwifi.c index c9b1a16..50d824f 100644 --- a/user/cgiwifi.c +++ b/user/cgiwifi.c @@ -167,6 +167,7 @@ static void ICACHE_FLASH_ATTR scanStartCb(void *arg) { } static int ICACHE_FLASH_ATTR cgiWiFiStartScan(HttpdConnData *connData) { + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. jsonHeader(connData, 200); if (!cgiWifiAps.scanInProgress) { cgiWifiAps.scanInProgress = 1; @@ -178,6 +179,7 @@ static int ICACHE_FLASH_ATTR cgiWiFiStartScan(HttpdConnData *connData) { } static int ICACHE_FLASH_ATTR cgiWiFiGetScan(HttpdConnData *connData) { + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. char buff[2048]; int len; @@ -428,10 +430,7 @@ int ICACHE_FLASH_ATTR cgiWiFiSetMode(HttpdConnData *connData) { int len; char buff[1024]; - if (connData->conn==NULL) { - // Connection aborted. Clean up. - return HTTPD_CGI_DONE; - } + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. len=httpdFindArg(connData->getArgs, "mode", buff, sizeof(buff)); if (len!=0) { @@ -512,6 +511,7 @@ int ICACHE_FLASH_ATTR cgiWiFiConnStatus(HttpdConnData *connData) { char buff[1024]; int len; + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. jsonHeader(connData, 200); len = os_sprintf(buff, "{"); @@ -547,9 +547,7 @@ int ICACHE_FLASH_ATTR cgiWiFiConnStatus(HttpdConnData *connData) { int ICACHE_FLASH_ATTR cgiWifiInfo(HttpdConnData *connData) { char buff[1024]; - if (connData->conn==NULL) { - return HTTPD_CGI_DONE; // Connection aborted - } + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. os_strcpy(buff, "{"); printWifiInfo(buff+1); diff --git a/user/log.c b/user/log.c index cb7a683..9103a41 100644 --- a/user/log.c +++ b/user/log.c @@ -87,6 +87,7 @@ ajaxLog(HttpdConnData *connData) { int log_len = (log_wr+BUF_MAX-log_rd) % BUF_MAX; // num chars in log_buf int start = 0; // offset onto log_wr to start sending out chars + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. jsonHeader(connData, 200); // figure out where to start in buffer based on URI param @@ -128,6 +129,7 @@ static char *dbg_mode[] = { "auto", "off", "on" }; int ICACHE_FLASH_ATTR ajaxLogDbg(HttpdConnData *connData) { + if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. char buff[512]; int len, status = 400; len = httpdFindArg(connData->getArgs, "mode", buff, sizeof(buff));