Bug 59644 - It is possible to have uncontrolled httpd instance
Summary: It is possible to have uncontrolled httpd instance
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Core (show other bugs)
Version: 2.4.20
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-31 09:40 UTC by Nikolay
Modified: 2016-05-31 09:40 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay 2016-05-31 09:40:29 UTC
At first about the problem. If start Apache twice, it may happen that second instance will ignore the first one:

> % sudo apachectl restart && sudo apachectl restart
> httpd not running, trying to start
> httpd not running, trying to start
> % ps -ef | grep httpd | grep -v grep
> root     28608     1  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> daemon   28613 28608  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> daemon   28614 28608  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> daemon   28615 28608  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> daemon   28616 28608  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> root     28617     1  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> daemon   28699 28617  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> daemon   28700 28617  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> daemon   28701 28617  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> daemon   28702 28617  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart

And here are the problem, one of httpd groups becomes uncontrolled by the usual way:

> % sudo apachectl stop
> % sudo apachectl stop
> httpd (no pid file) not running
> % ps -ef | grep httpd | grep -v grep
> root     28608     1  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> daemon   28613 28608  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> daemon   28614 28608  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> daemon   28615 28608  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart
> daemon   28616 28608  0 04:58 ?        00:00:00 /usr/local/apache2/bin/httpd -k restart

Second httpd instance overwrites pid file (from log: "pid file /usr/local/apache2/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?") so there are no regular way to control first httpd instance.

How to reproduce. It seems httpd should be quite heavy to achieve this (with a lot of modules). Default way (configure && make && sudo make install) works ok, but for example using this way it reproduces for me on clean CentOS 7.1:

> % configure --enable-modules=all --enable-mods-static=all
> % make && sudo make install

Issue might sitting there for a lot of time. In 2.2 it is similar with one conceptual difference:

> % sudo apachectl restart && sudo apachectl restart
> httpd not running, trying to start
> httpd not running, trying to start
> (98)Address already in use: make_sock: could not bind to address [::]:80
> (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
> no listening sockets available, shutting down
> Unable to open logs

That inability to bind port saves from second httpd instance. But since 2.4.17 there is unconditionally used SO_REUSEPORT on listening socket (even if feature that it is intended for is not used), so binding of already bound port goes without errors.