Skip to content

bhm: improve shutdown sequence#41862

Merged
yezhizhen merged 1 commit intoservo:mainfrom
webbeef:bhm-multiprocess-exit
Jan 14, 2026
Merged

bhm: improve shutdown sequence#41862
yezhizhen merged 1 commit intoservo:mainfrom
webbeef:bhm-multiprocess-exit

Conversation

@webbeef
Copy link
Copy Markdown
Contributor

@webbeef webbeef commented Jan 12, 2026

Instead of exiting immediately when control_port disconnects, the BHM now:

  1. Signals all registered components to exit
  2. Enter shut down state by turning off the control_port
  3. Runs untils self.port disconnects

Testing: Manual testing with ./mach run -M and checking the lack of shutdown crash.
Fixes: #41437

cc @gterzian

@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jan 12, 2026
Copy link
Copy Markdown
Member

@gterzian gterzian left a comment

Choose a reason for hiding this comment

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

LGTM with one change; thank you

// have finished. Instead of exiting immediately, we signal
// all components to exit and continue running until they all
// unregister (indicated by `self.port` disconnecting).
if !self.shutting_down {
Copy link
Copy Markdown
Member

@gterzian gterzian Jan 13, 2026

Choose a reason for hiding this comment

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

If this is true we should log an error because it means the port was dropped outside of the normal clean-shut down flow(the constellation panicked).

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Jan 13, 2026
recv(self.port) -> event => {
if let Ok(event) = event {
Some(event)
// Helper enum to collect messages from different ports depeneding
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.

Suggested change
// Helper enum to collect messages from different ports depeneding
// Helper enum to collect messages from different ports depending

Instead of exiting immediately when control_port disconnects, the BHM now:
1. Signals all registered components to exit
2. Enter shut down state by turning off the control_port
3. Runs untils self.port disconnects

Fixes servo#41437

Signed-off-by: webbeef <me@webbeef.org>
@webbeef webbeef force-pushed the bhm-multiprocess-exit branch from 792d021 to e8bf917 Compare January 13, 2026 16:08
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jan 13, 2026
@yezhizhen yezhizhen added this pull request to the merge queue Jan 14, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 14, 2026
@yezhizhen yezhizhen removed this pull request from the merge queue due to a manual request Jan 14, 2026
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 14, 2026
},
BhmMessage::ToggleSampler(rate, max_duration) => {
if self.sampling_duration.is_some() {
println!("Enabling profiler.");
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.

I was thinking if we should change this println. But should be fine as users want to have response when toggle.

@yezhizhen yezhizhen added this pull request to the merge queue Jan 14, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 14, 2026
Merged via the queue into servo:main with commit 6ee1b43 Jan 14, 2026
35 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when quitting in multiprocess mode

5 participants