-
Notifications
You must be signed in to change notification settings - Fork 31
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
httpd-stop doesn't stop the process #23
Comments
I'm unable to reproduce your exact example. But, yes, httpd-stop doesn't
close ongoing HTTP requests. It only stops listening for new requests.
It probably should kill all the on-going requests, though. This is not
normally a problem since requests are usually served quickly, but, for
example, long polling will remain open.
|
Thanks @skeeto. It would be nice to be able to stop all the processes. I only need to serve a single response to a single request (as part of an OAuth2 exchange). Would you be willing to accept a PR? As an aside, I listened to your interview with Sascha Chua on her Emacs Chat podcast today - very entertaining! Thanks for all your awesome contributions to the world of Emacs! |
Thank you for the kind words.
Did you have a specific approach in mind for fixing it? My thoughts:
When a request arrives (filter), the new connection process object is
put into a collection. When the connection closes it is removed from the
collection (sentinel). That allows httpd-stop to abruptly close any
on-going connections by iterating over the collection.
The collection should be a hash table keyed on the process objects
themselves, acting like a set. Perhaps it should even have weak keys so
that, should somehow process objects not get cleaned up by the sentinel,
they'll still fall out of the table eventually. (I believe dead process
objects are no longer held by the process list, so they're free to be
garbage collected when no more references exist.)
|
I think that would be a great approach! Additionally, I am trying to tread lightly and only stop if the "daemon" isn't already running. So I check the status and only start if not already started. I keep track of said state and kill processes only if it wasn't already running. My horrible hacks are here, starting around line 88. Perhaps there could be a few functions to handle this? |
If you're referring to the way httpd-stop is called by httpd-start, I'm
not wedded to this behavior and it's only that way because it was
simple. If the server is already running, httpd-start should really do
nothing. With your proposed change of killing ongoing requests, the
stop-and-restart behavior certainly makes a lot less sense.
I agree that filtering the process list based on string name as you do
is a horrible hack. :-) That won't be necessary if the server tracks
connection processes itself.
|
I just realized I wasn't explicit about this yet: I'm happy to accept a
PR that fixes this issue.
|
Awesome thank you! I'll take a stab at it in the next few days. |
I also have this issue, any update on this? 😕 Thanks! (dolist (proc (process-list))
(when (string-prefix-p "httpd" (process-name proc))
(delete-process proc))) This will work. 🤔 |
I see that when I have a servlet and it has accepted at least one request (in my case to
http://localhost:8080/?foo=bar
), the process name is no longerhttpd
so the'#httpd-stop
function does not stop the network process. Here is the code I'm running:There seem to be two processes now:
The text was updated successfully, but these errors were encountered: