Skip to content

fix: retry Transceiver calls interrupted by EINTR#1299

Open
mx6436 wants to merge 3 commits intoMaaXYZ:mainfrom
mx6436:fix/handle-EINTR
Open

fix: retry Transceiver calls interrupted by EINTR#1299
mx6436 wants to merge 3 commits intoMaaXYZ:mainfrom
mx6436:fix/handle-EINTR

Conversation

@mx6436
Copy link
Copy Markdown
Contributor

@mx6436 mx6436 commented Apr 28, 2026

MaaEnd/MaaEnd#2539

Summary by Sourcery

错误修复:

  • 当 ZeroMQ 的发送、接收和轮询操作因 EINTR 失败时,改为进行重试,而不是将其视为不可恢复的严重错误。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Retry ZeroMQ send, receive, and poll operations when they fail with EINTR instead of treating them as hard errors.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些总体反馈:

  • retry_on_eintr 辅助函数在遇到反复出现的 EINTR 时会无限循环;建议增加一个最大重试次数或超时参数,以避免在病态场景下出现无界的忙等循环。
  • 为了一致性和可读性,你可能希望让 poll_item 也使用 retry_on_eintr(或类似的循环),而不是在遇到 EINTR 时特判并返回 false,这样可以在 send/recv/poll 操作之间统一 EINTR 的处理语义。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- The `retry_on_eintr` helper loops indefinitely on repeated `EINTR`; consider adding a maximum retry count or timeout parameter so a pathological scenario doesn’t cause an unbounded tight loop.
- For consistency and clarity, you might want `poll_item` to also use `retry_on_eintr` (or a similar loop) rather than special-casing EINTR with a `false` return, so EINTR handling semantics are uniform across send/recv/poll operations.

Sourcery 对开源项目是免费的——如果你喜欢我们的评审,请考虑分享给更多人 ✨
帮我变得更有用吧!请在每条评论上点 👍 或 👎,我会根据你的反馈改进之后的评审。
Original comment in English

Hey - I've left some high level feedback:

  • The retry_on_eintr helper loops indefinitely on repeated EINTR; consider adding a maximum retry count or timeout parameter so a pathological scenario doesn’t cause an unbounded tight loop.
  • For consistency and clarity, you might want poll_item to also use retry_on_eintr (or a similar loop) rather than special-casing EINTR with a false return, so EINTR handling semantics are uniform across send/recv/poll operations.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `retry_on_eintr` helper loops indefinitely on repeated `EINTR`; consider adding a maximum retry count or timeout parameter so a pathological scenario doesn’t cause an unbounded tight loop.
- For consistency and clarity, you might want `poll_item` to also use `retry_on_eintr` (or a similar loop) rather than special-casing EINTR with a `false` return, so EINTR handling semantics are uniform across send/recv/poll operations.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

MistEO

This comment was marked as off-topic.

Comment thread source/AgentCommon/Transceiver.cpp Outdated
template <typename Func>
static auto retry_on_eintr(std::string_view operation, Func&& func)
{
while (true) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上面是 AI 回的。不太行,哪能这么玩

Comment thread source/AgentCommon/Transceiver.cpp Outdated
}
catch (const zmq::error_t& e) {
if (!is_eintr(e)) {
throw;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不符合 maafw 项目风格

Comment thread source/AgentCommon/Transceiver.cpp Outdated
if (!is_eintr(e)) {
throw;
}
LogTrace << "retry after EINTR" << VAR(operation);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

什么叫传个参数还是 string 只是为了打印(

mx6436 added 2 commits April 29, 2026 00:40
Drop the try/catch helper and string-only-for-logging argument per review.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants