Skip to content

Allow driver's maintenance loop to return#163

Merged
BYGX-wcr merged 2 commits into
sonic-net:masterfrom
BYGX-wcr:allow-mainteinance-loop-return
May 17, 2026
Merged

Allow driver's maintenance loop to return#163
BYGX-wcr merged 2 commits into
sonic-net:masterfrom
BYGX-wcr:allow-mainteinance-loop-return

Conversation

@BYGX-wcr
Copy link
Copy Markdown
Contributor

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

… actor is idle

Signed-off-by: BYGX-wcr <wcr@live.cn>
Copilot AI review requested due to automatic review settings May 14, 2026 20:35
@mssonicbld
Copy link
Copy Markdown

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_loop to return when both queued and unacked messages are empty.
  • Updates ActorDriver::run to 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;
Signed-off-by: BYGX-wcr <wcr@live.cn>
@mssonicbld
Copy link
Copy Markdown

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@BYGX-wcr BYGX-wcr merged commit 301af43 into sonic-net:master May 17, 2026
4 checks passed
@BYGX-wcr BYGX-wcr deleted the allow-mainteinance-loop-return branch May 17, 2026 19:31
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.

4 participants