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

Stopping the server (revisit #139) #200

Open
Diggsey opened this issue Dec 25, 2018 · 1 comment
Open

Stopping the server (revisit #139) #200

Diggsey opened this issue Dec 25, 2018 · 1 comment

Comments

@Diggsey
Copy link
Contributor

Diggsey commented Dec 25, 2018

In #139 , there's a suggestion to use loop { server.poll() }. However, this is much more CPU-wasteful than calling server.run(), and I think there are several things rouille could do to make this easier.

  • Server::poll_timeout. The underlying server provides the recv_timeout method, so it would be very easy to add this: using even a small timeout means the CPU usage will be much lower than calling poll in a loop.

  • Server::handle. This would return a Send + Clone handle which has a method to shutdown the server. This could be implemented by closing the underlying socket, triggering a wake-up, or by setting a flag and then initiating a dummy connection.

@LPGhatguy
Copy link

Another approach for this would be to let Server accept an mpsc::Receiver as a shutdown signal, letting the user give the other half of the channel to whatever wants to shut the server down.

This is the approach that Hyper uses, but with a futures::sync::oneshot::channel pair instead of an std::sync::mpsc::channel pair.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants