Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc server 优雅的关闭方式 #7

Open
Kiprey opened this issue Aug 10, 2022 · 0 comments
Open

rpc server 优雅的关闭方式 #7

Kiprey opened this issue Aug 10, 2022 · 0 comments

Comments

@Kiprey
Copy link

Kiprey commented Aug 10, 2022

根据 Server::start 的函数签名:

pub fn start(&mut self) -> Result<()>

可以看到这里使用的是可变借用。该函数一旦执行将一直阻塞,直到 listen 用 fd 被关闭。
而这个 fd 只会在 Server::close 函数中被关闭,以下是它的函数签名:

pub fn close(&self)

可以看到这里有一个不可变借用。

由于 Rust 语言限制同一个变量的可变借用和不可变借用不能同时存在,因此在调用 start 函数之后,无法再调用 close 函数将其关闭。
请问有无优雅的方式来将正在监听的 RPC Server 关闭?

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

No branches or pull requests

1 participant