Allow driver's maintenance loop to return#163
Merged
BYGX-wcr merged 2 commits intoMay 17, 2026
Conversation
… actor is idle Signed-off-by: BYGX-wcr <wcr@live.cn>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This PR updates the swbus actor driver maintenance flow so the maintenance future can return when there is no outgoing work, allowing deleted actors to re-check whether they can terminate.
Changes:
- Allows
Outgoing::drive_maintenance_loopto return when both queued and unacked messages are empty. - Updates
ActorDriver::runto handle the maintenance loop returning instead of treating it as unreachable.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
crates/swbus-actor/src/state/outgoing.rs |
Adds the empty-queue return path to the outgoing maintenance loop. |
crates/swbus-actor/src/driver.rs |
Replaces the unreachable maintenance branch with a debug log. |
Comment on lines
+152
to
+153
| } | ||
| else if self.unacked_messages.is_empty() { |
Comment on lines
+153
to
+157
| else if self.unacked_messages.is_empty() { | ||
| // if both queued messages and unacked messages queues are empty | ||
| // there is nothing to do maintenance, we will return to check if | ||
| // the actor is marked as deleted | ||
| return; |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
zjswhhh
approved these changes
May 16, 2026
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.
What I did
Allow the drive_maintenance_loop function to return when the queued messages queue and unacked messages queue are both empty.
Why I did it
Before this change, if the Actor has some unacked messages held in the queue and these unacked messages never gets replied, the Actor cannot be deleted even though the the unacked messages will be dropped. This is because the Actor only could exit when the message reception branch won the tokio::select. If there is no messages being received, the actor is stuck since neither drive_maintenance_loop and message reception branch returns.
How I verified it
Run sonic-mgmt tests and ensure the actors are deleted afterwards
Details if related