regression, webserver callbacks before reset crashes

any webserver event handlers bound before the webserver new reset would cause memory access issues when triggered.

Should remove all events on reset or make memory safe, not sure if this is the correct way to be reseting the webserver, but there were issues with the ports not releasing etc.
This commit is contained in:
tablatronix
2022-03-11 08:34:08 -06:00
parent 0d61a6b55f
commit 0994c4b3f8
2 changed files with 11 additions and 9 deletions
+9 -8
View File
@@ -587,6 +587,15 @@ void WiFiManager::setupHTTPServer(){
}
server.reset(new WM_WebServer(_httpPort));
// This is not the safest way to reset the webserver, it can cause crashes on callbacks initilized before this and since its a shared pointer...
if ( _webservercallback != NULL) {
#ifdef WM_DEBUG_LEVEL
DEBUG_WM(DEBUG_VERBOSE,F("[CB] _webservercallback calling"));
#endif
_webservercallback();
}
// @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first
/* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */
@@ -628,14 +637,6 @@ void WiFiManager::setupDNSD(){
void WiFiManager::setupConfigPortal() {
if ( _webservercallback != NULL) {
#ifdef WM_DEBUG_LEVEL
DEBUG_WM(DEBUG_VERBOSE,F("[CB] _webservercallback calling"));
#endif
_webservercallback();
}
// @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first
setupHTTPServer();
if(_preloadwifiscan) WiFi_scanNetworks(true,true); // preload wifiscan , async
@@ -24,6 +24,7 @@ WiFiManager wm;
// TEST OPTION FLAGS
bool TEST_CP = false; // always start the configportal, even if ap found
bool TEST_CP = true; // always start the configportal, even if ap found
int TESP_CP_TIMEOUT = 90; // test cp timeout
bool TEST_NET = true; // do a network test after connect, (gets ntp time)
@@ -55,7 +56,7 @@ void saveParamCallback(){
}
void bindServerCallback(){
// wm.server->on("/custom",handleRoute); // this is now crashing esp32 for some reason
wm.server->on("/custom",handleRoute); // this is now crashing esp32 for some reason
// wm.server->on("/info",handleRoute); // you can override wm!
}