mirror of
https://github.com/apache/httpd.git
synced 2025-08-06 11:06:17 +00:00
Move setup_listeners to listen.c. This renames it to ap_setup_listeners,
and removes the duplicated code from all effected MPMs. The only this doesn't touch, is Windows. That MPM was using a different setup_listeners. If one of the Windows guys would like to modify the WinNT MPM to use the same setup_lsiteners, that would be VERY cool. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85809 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@ -72,7 +72,11 @@ struct ap_listen_rec {
|
||||
extern ap_listen_rec *ap_listeners;
|
||||
|
||||
void ap_listen_pre_config(void);
|
||||
#ifndef WIN32
|
||||
int ap_setup_listeners(server_rec *s);
|
||||
#else
|
||||
int ap_listen_open(process_rec *process, unsigned port);
|
||||
#endif
|
||||
const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg);
|
||||
const char *ap_set_listener(cmd_parms *cmd, void *dummy, const char *ips);
|
||||
const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy,
|
||||
|
@ -201,7 +201,9 @@ static void alloc_listener(process_rec *process, char *addr, unsigned int port)
|
||||
ap_listeners = new;
|
||||
}
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
static
|
||||
#endif
|
||||
int ap_listen_open(process_rec *process, unsigned port)
|
||||
{
|
||||
ap_pool_t *pconf = process->pconf;
|
||||
@ -241,6 +243,20 @@ int ap_listen_open(process_rec *process, unsigned port)
|
||||
return num_open ? 0 : -1;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
int ap_setup_listeners(server_rec *s)
|
||||
{
|
||||
ap_listen_rec *lr;
|
||||
int num_listeners = 0;
|
||||
if (ap_listen_open(s->process, s->port)) {
|
||||
return 0;
|
||||
}
|
||||
for (lr = ap_listeners; lr; lr = lr->next) {
|
||||
num_listeners++;
|
||||
}
|
||||
return num_listeners;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ap_listen_pre_config(void)
|
||||
{
|
||||
|
@ -289,19 +289,6 @@ static void set_signals(void)
|
||||
ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGWINCH)");
|
||||
}
|
||||
|
||||
static int setup_listeners(server_rec *s)
|
||||
{
|
||||
ap_listen_rec *lr;
|
||||
int num_listeners = 0;
|
||||
if (ap_listen_open(s->process, s->port)) {
|
||||
return 0;
|
||||
}
|
||||
for (lr = ap_listeners; lr; lr = lr->next) {
|
||||
num_listeners++;
|
||||
}
|
||||
return num_listeners;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
* Here follows a long bunch of generic server bookkeeping stuff...
|
||||
*/
|
||||
@ -692,7 +679,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((num_listening_sockets = setup_listeners(ap_server_conf)) < 1) {
|
||||
if ((num_listening_sockets = ap_setup_listeners(ap_server_conf)) < 1) {
|
||||
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
|
||||
"no listening sockets available, shutting down");
|
||||
return 1;
|
||||
|
@ -376,20 +376,6 @@ static void set_signals(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int setup_listeners(server_rec *s)
|
||||
{
|
||||
ap_listen_rec *lr;
|
||||
int num_listeners = 0;
|
||||
|
||||
if (ap_listen_open(s->process, s->port)) {
|
||||
return 0;
|
||||
}
|
||||
for (lr = ap_listeners; lr; lr = lr->next) {
|
||||
num_listeners++;
|
||||
}
|
||||
return num_listeners;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
* Here follows a long bunch of generic server bookkeeping stuff...
|
||||
*/
|
||||
@ -1026,7 +1012,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
|
||||
exit(1);
|
||||
}
|
||||
ap_server_conf = s;
|
||||
if ((num_listenfds = setup_listeners(ap_server_conf)) < 1) {
|
||||
if ((num_listenfds = ap_setup_listeners(ap_server_conf)) < 1) {
|
||||
/* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
|
||||
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
|
||||
"no listening sockets available, shutting down");
|
||||
|
@ -277,19 +277,6 @@ static void set_signals(void)
|
||||
ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGWINCH)");
|
||||
}
|
||||
|
||||
static int setup_listeners(server_rec *s)
|
||||
{
|
||||
ap_listen_rec *lr;
|
||||
int num_listeners = 0;
|
||||
if (ap_listen_open(s->process, s->port)) {
|
||||
return 0;
|
||||
}
|
||||
for (lr = ap_listeners; lr; lr = lr->next) {
|
||||
num_listeners++;
|
||||
}
|
||||
return num_listeners;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
* Here follows a long bunch of generic server bookkeeping stuff...
|
||||
*/
|
||||
@ -717,7 +704,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
|
||||
ap_server_conf = s;
|
||||
port_of_death = create_port(1, "httpd_port_of_death");
|
||||
|
||||
if ((num_listenfds = setup_listeners(ap_server_conf)) < 1) {
|
||||
if ((num_listenfds = ap_setup_listeners(ap_server_conf)) < 1) {
|
||||
/* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
|
||||
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, errno, s,
|
||||
"no listening sockets available, shutting down");
|
||||
|
@ -373,19 +373,6 @@ static void set_signals(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int setup_listeners(server_rec *s)
|
||||
{
|
||||
ap_listen_rec *lr;
|
||||
int num_listeners = 0;
|
||||
if (ap_listen_open(s->process, s->port)) {
|
||||
return 0;
|
||||
}
|
||||
for (lr = ap_listeners; lr; lr = lr->next) {
|
||||
num_listeners++;
|
||||
}
|
||||
return num_listeners;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
* Here follows a long bunch of generic server bookkeeping stuff...
|
||||
*/
|
||||
@ -1049,7 +1036,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
|
||||
exit(1);
|
||||
}
|
||||
ap_server_conf = s;
|
||||
if ((num_listensocks = setup_listeners(ap_server_conf)) < 1) {
|
||||
if ((num_listensocks = ap_setup_listeners(ap_server_conf)) < 1) {
|
||||
/* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
|
||||
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
|
||||
"no listening sockets available, shutting down");
|
||||
|
@ -1283,29 +1283,6 @@ static void perform_idle_server_maintenance(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int setup_listeners(server_rec *s)
|
||||
{
|
||||
ap_listen_rec *lr;
|
||||
int sockdes;
|
||||
|
||||
if (ap_listen_open(s->process, s->port)) {
|
||||
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
|
||||
"no listening sockets available, shutting down");
|
||||
return -1;
|
||||
}
|
||||
|
||||
listenmaxfd = -1;
|
||||
FD_ZERO(&listenfds);
|
||||
for (lr = ap_listeners; lr; lr = lr->next) {
|
||||
ap_get_os_sock(&sockdes, lr->sd);
|
||||
FD_SET(sockdes, &listenfds);
|
||||
if (sockdes > listenmaxfd) {
|
||||
listenmaxfd = sockdes;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Useful to erase the status of children that might be from previous
|
||||
* generations */
|
||||
static void ap_prefork_force_reset_connection_status(long conn_id)
|
||||
@ -1337,7 +1314,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
|
||||
|
||||
ap_log_pid(pconf, ap_pid_fname);
|
||||
|
||||
if (setup_listeners(s)) {
|
||||
if (ap_setup_listeners(s)) {
|
||||
/* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
|
||||
return 1;
|
||||
}
|
||||
|
@ -741,27 +741,6 @@ int ap_stop_signalled(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int setup_listeners(ap_pool_t *pchild, ap_pollfd_t **listen_poll)
|
||||
{
|
||||
ap_listen_rec *lr;
|
||||
int numfds = 0;
|
||||
|
||||
for (lr = ap_listeners; lr; lr = lr->next) {
|
||||
numfds++;
|
||||
}
|
||||
|
||||
ap_setup_poll(listen_poll, numfds, pchild);
|
||||
|
||||
for (lr = ap_listeners; lr; lr = lr->next) {
|
||||
ap_add_poll_socket(*listen_poll, lr->sd, APR_POLLIN);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void child_main(void *child_num_arg)
|
||||
{
|
||||
ap_listen_rec *lr = NULL;
|
||||
@ -796,7 +775,7 @@ static void child_main(void *child_num_arg)
|
||||
THREAD_GLOBAL(pchild) = pchild;
|
||||
ap_create_pool(&ptrans, pchild);
|
||||
|
||||
if (setup_listeners(pchild, &listen_poll)) {
|
||||
if (ap_setup_listeners(pchild, &listen_poll)) {
|
||||
clean_child_exit(1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user