-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: resend msgs when client_thread send failed #1816
Fix: resend msgs when client_thread send failed #1816
Conversation
} | ||
to_send_.erase(iter); | ||
NotifyWrite(ip_port); | ||
} | ||
} else if (ti.notify_type() == kNotiClose) { | ||
LOG(INFO) << "received kNotiClose"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some improvements and bug risks to consider in the provided code patch:
Improvements:
- Remove the unnecessary blank line: The blank line at line 32 can be removed for cleaner code formatting.
Bug Risks:
- Accessing invalidated iterators: After swapping
msgs
withiter->second
, the loop that follows assumes thatmsgs
contains the originally stored messages. However, if there are other parts of the code that accessto_send_[ip_port]
concurrently and modify it after the swap, the loop may produce unexpected results or even result in undefined behavior due to accessing invalidated iterators. Consider using a different approach to process the messages to avoid this risk.
Overall, without full context and knowledge of the entire codebase, it's difficult to provide an exhaustive review. It's recommended to thoroughly test the modified code for any potential issues and ensure that all other parts of the codebase (not included in the provided snippet) work correctly with these modifications.
resend msgs when client_thread send failed and narrow down critical section
Fixes: #1815