Wayland: 在 EventFlow::Poll 期间,flush() 返回 WouldBlock 后,应用程序会默默退出(临时的 EAGAIN 会被视为致命错误)
作者: SilenceNoob创建于 2026年8月14日更新于 2026年8月14日
在 platform/src/os/linux/wayland/wayland_app.rs 中,事件循环的 EventFlow::Poll 分支将任何 flush() 错误视为致命错误:
fn event_loop_poll(&mut self) {
if let Err(err) = self.event_queue.flush() {
crate::warning!("Wayland flush failed: {}", err);
self.terminate_event_loop();
return;
}
...同一文件中的 EventFlow::Wait 分支(约在第 58 行)已经知道 WouldBlock 是临时的,可以安全地重试:
// A WouldBlock 仅表示套接字缓冲区已满;消息仍保留在队列中,下一个循环迭代将重试,因此只有断开连接才是致命的。
if let Err(err) = self.event_queue.flush() {
let transient = matches!(
&err,
wayland_client::backend::WaylandError::Io(io) if io.kind() == std::io::ErrorKind::WouldBlock
);
if !transient {
crate::warning!("Wayland flush failed: {}", err);
self.terminate_event_loop();
return;
}
}这确实是安全的重试:
内容来源: makepad/makepad