fix: stop XCB event polling after connection failure - #489
Conversation
Detect XCB connection errors before and after event dispatch and flushing. Keep the socket notifier as a member, disable it after the first connection failure, and latch the failed state to prevent repeated wakeups and log flooding. 在事件分发及刷新前后检测 XCB 连接错误。保存 socket notifier,并在首次连接失败后将其禁用,同时锁存失败状态,避免持续唤醒和重复日志。 Log: stop XCB event polling after connection failure
There was a problem hiding this comment.
Sorry @yixinshark, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yixinshark The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideAdds centralized XCB connection error handling to the tray util, and uses it to early‑out event dispatch and disable the socket notifier once the X11 connection fails, preventing busy‑looping on POLLHUP and repeated warnings. Sequence diagram for X11 connection failure handling in event dispatchsequenceDiagram
participant QSocketNotifier
participant Util
participant xcb_connection_has_error
QSocketNotifier->>Util: QSocketNotifier::activated
Util->>Util: dispatchEvents(DispatchEventsMode::Poll)
Util->>Util: handleX11ConnectionError()
alt [error detected]
Util->>xcb_connection_has_error: xcb_connection_has_error(m_x11connection)
Util-->>QSocketNotifier: m_x11EventNotifier->setEnabled(false)
Util-->>Util: return (early out)
else [no error]
Util->>Util: pollEventFunc(...)
Util->>Util: handleX11ConnectionError()
Util->>Util: xcb_flush(connection)
Util->>Util: handleX11ConnectionError()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
| } | ||
|
|
||
| xcb_flush(connection); | ||
| handleX11ConnectionError(); |
| qCWarning(TRAYUTIL, "Attempting to dispatch X11 events with no connection"); | ||
| return; | ||
| } | ||
| if (m_x11ConnectionFailed || handleX11ConnectionError()) { |
There was a problem hiding this comment.
m_x11ConnectionFailed 这个在handleX11ConnectionError里已经判断了,上面的connection判断也可以去掉了吧,
Summary
Test plan
cmake --build build --target application-tray -j2git diff --checkPOLLIN|POLLHUPafter the X11/XCB peer disconnected.Summary by Sourcery
Handle X11/XCB connection failures in the application tray event loop to avoid runaway polling after disconnects.
Bug Fixes:
Enhancements: