File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,28 @@ pub fn shutdown_master_listener_unix() -> io::Result<()> {
112112
113113 if let Some ( ( handle, fd) ) = listener_data {
114114 stop_listening ( fd) ;
115- handle. join ( ) ;
115+
116+ // Try to join with a timeout to avoid hanging the shutdown
117+ // We spawn a helper thread to do the join so we can implement a timeout
118+ let ( tx, rx) = std:: sync:: mpsc:: channel ( ) ;
119+ std:: thread:: spawn ( move || {
120+ let result = handle. join ( ) ;
121+ let _ = tx. send ( result) ;
122+ } ) ;
123+
124+ // Wait up to 2 seconds for clean shutdown (including time for tokio runtime shutdown)
125+ match rx. recv_timeout ( Duration :: from_millis ( 2000 ) ) {
126+ Ok ( Ok ( ( ) ) ) => {
127+ // Clean shutdown
128+ }
129+ Ok ( Err ( _) ) => {
130+ error ! ( "Listener thread panicked during shutdown" ) ;
131+ }
132+ Err ( _) => {
133+ // Timeout - thread didn't exit in time
134+ // This is acceptable as the OS will clean up when the process exits
135+ }
136+ }
116137 }
117138
118139 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments