@@ -4205,6 +4205,10 @@ static void _webui_interface_bind_handler(webui_event_t* e) {
42054205 _webui_mutex_lock (& _webui .mutex_async_response );
42064206 if (event_inf -> done ) done = true;
42074207 _webui_mutex_unlock (& _webui .mutex_async_response );
4208+
4209+ if (_webui_mutex_app_is_exit_now (WEBUI_MUTEX_GET_STATUS )) {
4210+ break ; // App is exiting, Stop waiting.
4211+ }
42084212 }
42094213 }
42104214
@@ -4915,6 +4919,8 @@ static bool _webui_is_mg_client_valid(_webui_window_t* win, const struct mg_conn
49154919 // The `mg_get_xxx()` functions may crash if the client is not valid.
49164920 // So we need to check if the server is still running. Otherwise,
49174921 // we consider the client is freed and invalid.
4922+ if (_webui_mutex_app_is_exit_now (WEBUI_MUTEX_GET_STATUS ))
4923+ return false; // App is exiting, Client is not valid
49184924 if (!client ) {
49194925 return false; // Client is not valid
49204926 }
@@ -5292,6 +5298,10 @@ static const void* _webui_call_external_file_handler_cb(_webui_window_t* win, co
52925298 if (win -> file_handler_async_done )
52935299 done = true;
52945300 _webui_mutex_unlock (& _webui .mutex_async_response );
5301+
5302+ if (_webui_mutex_app_is_exit_now (WEBUI_MUTEX_GET_STATUS )) {
5303+ break ; // App is exiting, Stop waiting.
5304+ }
52955305 }
52965306 callback_resp = win -> file_handler_async_response ;
52975307 * length = win -> file_handler_async_len ;
@@ -9235,6 +9245,10 @@ static void _webui_window_event(
92359245 _webui_mutex_lock (& _webui .mutex_async_response );
92369246 if (event_inf -> done ) done = true;
92379247 _webui_mutex_unlock (& _webui .mutex_async_response );
9248+
9249+ if (_webui_mutex_app_is_exit_now (WEBUI_MUTEX_GET_STATUS )) {
9250+ break ; // App is exiting, Stop waiting.
9251+ }
92389252 }
92399253 }
92409254 }
@@ -9808,6 +9822,9 @@ static void _webui_get_cookies(const struct mg_connection* client, char* buffer)
98089822 _webui_log_debug ("[Core]\t\t_webui_get_cookies()\n" );
98099823 #endif
98109824
9825+ if (_webui_mutex_app_is_exit_now (WEBUI_MUTEX_GET_STATUS ))
9826+ return ; // App is exiting, Stop getting cookies.
9827+
98119828 if (!_webui_is_mg_client_valid (NULL , client ))
98129829 return ; // Client is not valid
98139830
@@ -11446,6 +11463,10 @@ static void _webui_ws_process(
1144611463 _webui_mutex_lock (& _webui .mutex_async_response );
1144711464 if (event_inf -> done ) done = true;
1144811465 _webui_mutex_unlock (& _webui .mutex_async_response );
11466+
11467+ if (_webui_mutex_app_is_exit_now (WEBUI_MUTEX_GET_STATUS )) {
11468+ break ; // App is exiting, Stop waiting.
11469+ }
1144911470 }
1145011471 }
1145111472 }
0 commit comments