Skip to content

fix: capture tokio runtime handle for config reload callback#122

Merged
yinheli merged 1 commit intodevelopfrom
fix/config-reload-runtime
Jan 23, 2026
Merged

fix: capture tokio runtime handle for config reload callback#122
yinheli merged 1 commit intodevelopfrom
fix/config-reload-runtime

Conversation

@yinheli
Copy link
Owner

@yinheli yinheli commented Jan 22, 2026

No description provided.

Copy link

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 fixes a runtime panic that occurred when the file watcher callback tried to call tokio::runtime::Handle::current() from outside a Tokio runtime context. The fix captures the runtime handle when inside the async runtime context and passes it to the reload functions.

Changes:

  • Moved config watcher initialization into the Tokio runtime's async context
  • Created start_watch function to capture runtime handle and initialize the file watcher
  • Updated watch, reload_hosts, and reload_rules functions to accept and use the captured runtime handle

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/main.rs Moved start_watch call into rt.block_on async block to ensure it runs within runtime context
src/config/mod.rs Exported new start_watch function
src/config/load.rs Added start_watch function to capture runtime handle; updated internal functions to accept and use the captured handle instead of calling Handle::current() in callbacks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yinheli yinheli marked this pull request as ready for review January 23, 2026 01:27
@yinheli yinheli merged commit 4ca6077 into develop Jan 23, 2026
22 checks passed
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.

2 participants