File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -910,15 +910,32 @@ clear_main_control()
910
910
init_tmux_stream (& main_ctl -> stream , get_next_session_id (), INIT );
911
911
}
912
912
913
- void
914
- close_main_control ()
913
+ void close_main_control ()
915
914
{
915
+ if (!main_ctl ) {
916
+ debug (LOG_ERR , "main_ctl is NULL" );
917
+ return ;
918
+ }
919
+
920
+ // Clean up resources and state
916
921
clear_main_control ();
917
922
918
- event_base_dispatch (main_ctl -> connect_base );
919
- evdns_base_free (main_ctl -> dnsbase , 0 );
920
- event_base_free (main_ctl -> connect_base );
923
+ // Free event bases
924
+ if (main_ctl -> connect_base ) {
925
+ if (event_base_dispatch (main_ctl -> connect_base ) < 0 ) {
926
+ debug (LOG_ERR , "event_base_dispatch failed" );
927
+ }
928
+
929
+ if (main_ctl -> dnsbase ) {
930
+ evdns_base_free (main_ctl -> dnsbase , 0 );
931
+ main_ctl -> dnsbase = NULL ;
932
+ }
933
+
934
+ event_base_free (main_ctl -> connect_base );
935
+ main_ctl -> connect_base = NULL ;
936
+ }
921
937
938
+ // Free the main control structure
922
939
free_main_control ();
923
940
}
924
941
You can’t perform that action at this time.
0 commit comments