Make comm_timer_disable() safe to call repeatedly - #6
Open
rtrappman-dev wants to merge 1 commit into
Open
rtrappman-dev wants to merge 1 commit into
rtrappman-dev wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make
comm_timer_disable()idempotent by deleting the underlying event only when the timer is currently enabled.The existing implementation unconditionally called
ub_timer_del(), even when the timer had already been disabled. Repeated disable/delete sequences could therefore attempt to remove an event more than once, potentially causing event corruption or use-after-free behavior.Changes
timer->ev_timer->enabledbefore callingub_timer_del().Security / Reliability Impact
This hardens the asynchronous event lifecycle against double deletion of timer events.
comm_timer_disable()is used across timeout, retry, cleanup, and error-handling paths, where repeated disable operations can legitimately occur. Making the operation idempotent prevents invalid event deletion and reduces the risk of event-state corruption and use-after-free conditions.Testing
The change was verified against the
fix/comm_timer_disable()branch and preserves the existing timer lifecycle semantics: