@@ -898,36 +898,42 @@ free_main_control()
898
898
static void
899
899
clear_main_control ()
900
900
{
901
- // Sanity check
901
+ // Validate main control exists
902
902
if (!main_ctl ) {
903
- debug (LOG_ERR , "main_ctl is NULL" );
903
+ debug (LOG_ERR , "Cannot clear NULL main control " );
904
904
return ;
905
905
}
906
906
907
- // Clear timers
907
+ // Clear event timers
908
908
if (main_ctl -> ticker_ping ) {
909
- evtimer_del (main_ctl -> ticker_ping );
909
+ if (evtimer_del (main_ctl -> ticker_ping ) < 0 ) {
910
+ debug (LOG_ERR , "Failed to delete ticker ping timer" );
911
+ }
910
912
main_ctl -> ticker_ping = NULL ;
911
913
}
912
914
913
915
if (main_ctl -> tcp_mux_ping_event ) {
914
- evtimer_del (main_ctl -> tcp_mux_ping_event );
916
+ if (evtimer_del (main_ctl -> tcp_mux_ping_event ) < 0 ) {
917
+ debug (LOG_ERR , "Failed to delete TCP mux ping timer" );
918
+ }
915
919
main_ctl -> tcp_mux_ping_event = NULL ;
916
920
}
917
921
918
- // Clean up proxy clients and crypto context
919
- clear_all_proxy_client ();
920
- free_evp_cipher_ctx ();
921
-
922
- // Reset state variables
922
+ // Reset connection state
923
923
set_client_status (0 );
924
- pong_time = 0 ;
925
924
is_login = 0 ;
925
+ pong_time = 0 ;
926
+
927
+ // Clean up resources
928
+ clear_all_proxy_client ();
929
+ free_evp_cipher_ctx ();
926
930
927
- // Reinitialize multiplexer stream if TCP multiplexing is enabled
931
+ // Reinitialize TCP multiplexing if enabled
928
932
struct common_conf * conf = get_common_config ();
929
933
if (conf && conf -> tcp_mux ) {
930
- init_tmux_stream (& main_ctl -> stream , get_next_session_id (), INIT );
934
+ uint32_t session_id = get_next_session_id ();
935
+ init_tmux_stream (& main_ctl -> stream , session_id , INIT );
936
+ debug (LOG_DEBUG , "Reinitialized TCP mux stream with session ID %u" , session_id );
931
937
}
932
938
}
933
939
0 commit comments