Bug 27869 - stopping and starting httpd again immediately causes bind() to fail
Summary: stopping and starting httpd again immediately causes bind() to fail
Status: RESOLVED LATER
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mpm_worker (show other bugs)
Version: 2.0-HEAD
Hardware: Other other
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: MassUpdate
Depends on:
Blocks:
 
Reported: 2004-03-23 13:30 UTC by Arkadiusz Miskiewicz
Modified: 2018-11-07 21:08 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arkadiusz Miskiewicz 2004-03-23 13:30:04 UTC
The problem is that when using threaded MPM (like worker) and do
httpd -k stop
+ immediately start httpd again then it will fail with message
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443
no listening sockets available, shutting down

It seems that some threads do not end immediately and still use tcp port so bind 
fails. This happens only when some client is connected. If I stop httpd and wait 
for some time then after disconnection of client thread exits and I can start 
new httpd without any problems.

It seems like setting SO_REUSEADDR on listening sockets is good idea (or making 
httpd -s stop wait for all children/threads to exit).
Comment 1 Joshua Slive 2004-03-23 14:54:10 UTC
Why aren't you simply using a restart (graceful, preferably)?

It seems perfectly reasonable to me that a start won't work until a stop has
had a chance to finish.
Comment 2 Arkadiusz Miskiewicz 2004-03-26 12:47:50 UTC
Because I for example have new version of httpd with security fixes and I want 
to restart it as whole, or because I've modified httpd somehow and want new 
version to be started, or because there is new version from vendor. There is 
bunch of possible reasons.

Since it's perfectly reasonable that start won't work until a stop has
had a chance to finish then why httpd -k stop doesn't wait until it's really 
stopped? Right now httpd -k stop behaviour doesn't give any information whether 
httpd stopped or not.

Also why SO_REUSEADDR option on socket can't be used? It would help. 
Comment 3 Jeff Trawick 2004-03-26 13:11:37 UTC
>Also why SO_REUSEADDR option on socket can't be used?

This option is already used.  On most platforms (including everywhere that
worker MPM runs), SO_REUSEADDR does not allow an app to bind to a port that some
other process still has a listening socket on.  It only allows an app to bind to
a port where there are still TCP connections in terminating states (e.g.,
TIME_WAIT) which were established while some app was bound to the port.

How long is it taking the Apache processes to fully shut down in your
environment before Apache can successfully re-initialize?  Is anything written
to error log during shutdown?
Comment 4 Arkadiusz Miskiewicz 2004-03-26 14:38:25 UTC
I'm getting this
[Fri Mar 26 15:36:15 2004] [warn] child process 31232 still did not exit, 
sending a SIGTERM
[Fri Mar 26 15:36:15 2004] [warn] child process 31232 still did not exit, 
sending a SIGTERM
[Fri Mar 26 15:36:16 2004] [warn] child process 31232 still did not exit, 
sending a SIGTERM
[Fri Mar 26 15:36:20 2004] [error] child process 31232 still did not exit, 
sending a SIGKILL
[Fri Mar 26 15:36:37 2004] [notice] caught SIGTERM, shutting down

try to start apache with worker MPM, then telnet host 80 and leve it that way, 
then httpd -k stop; httpd to reproduce.

If httpd -k stop would wait then everything would be working nicely.
Comment 5 Paul Querna 2004-08-30 05:33:16 UTC
This seems like a Feature request to use SO_REUSEADDR or rety the bind() over a few seconds...
Comment 6 William A. Rowe Jr. 2018-11-07 21:08:17 UTC
Please help us to refine our list of open and current defects; this is a mass update of old and inactive Bugzilla reports which reflect user error, already resolved defects, and still-existing defects in httpd.

As repeatedly announced, the Apache HTTP Server Project has discontinued all development and patch review of the 2.2.x series of releases. The final release 2.2.34 was published in July 2017, and no further evaluation of bug reports or security risks will be considered or published for 2.2.x releases. All reports older than 2.4.x have been updated to status RESOLVED/LATER; no further action is expected unless the report still applies to a current version of httpd.

If your report represented a question or confusion about how to use an httpd feature, an unexpected server behavior, problems building or installing httpd, or working with an external component (a third party module, browser etc.) we ask you to start by bringing your question to the User Support and Discussion mailing list, see [https://httpd.apache.org/lists.html#http-users] for details. Include a link to this Bugzilla report for completeness with your question.

If your report was clearly a defect in httpd or a feature request, we ask that you retest using a modern httpd release (2.4.33 or later) released in the past year. If it can be reproduced, please reopen this bug and change the Version field above to the httpd version you have reconfirmed with.

Your help in identifying defects or enhancements still applicable to the current httpd server software release is greatly appreciated.