fix(event_loop): exit cleanly on OtherError(BrokenPipe) from compositor
calloop surfaces the closed-socket condition either as Error::IoError(BrokenPipe) — already handled — or as Error::OtherError wrapping an std::io::Error with kind BrokenPipe, which previously fell through to panic!(). Add a matching arm that downcasts the inner error and treats both forms the same: log and set exit_requested so the run loop terminates gracefully instead of unwinding.
This commit is contained in:
@@ -383,6 +383,24 @@ pub( crate ) fn try_run<A: App>( app: A ) -> Result<(), RunError>
|
|||||||
data.exit_requested = true;
|
data.exit_requested = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Err( calloop::Error::OtherError( ref e ) ) =>
|
||||||
|
{
|
||||||
|
// wayland-client surfaces the closed-socket condition as an
|
||||||
|
// OtherError wrapping an IoError rather than as the
|
||||||
|
// calloop::Error::IoError variant handled above. Treat any
|
||||||
|
// BrokenPipe / ConnectionReset here the same way: exit cleanly.
|
||||||
|
let is_closed = e.downcast_ref::<std::io::Error>()
|
||||||
|
.map( |io| matches!( io.kind(),
|
||||||
|
std::io::ErrorKind::BrokenPipe | std::io::ErrorKind::ConnectionReset ) )
|
||||||
|
.unwrap_or( false );
|
||||||
|
if is_closed
|
||||||
|
{
|
||||||
|
eprintln!( "ltk: wayland connection lost; exiting" );
|
||||||
|
data.exit_requested = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
panic!( "dispatch: {e:?}" );
|
||||||
|
}
|
||||||
Err( e ) => panic!( "dispatch: {e:?}" ),
|
Err( e ) => panic!( "dispatch: {e:?}" ),
|
||||||
}
|
}
|
||||||
// Any surface whose press has now crossed `long_press_duration`
|
// Any surface whose press has now crossed `long_press_duration`
|
||||||
|
|||||||
Reference in New Issue
Block a user