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,
ap_listeners = new;
}
-
+#ifndef WIN32
+static
+#endif
int ap_listen_open(process_rec *process, unsigned port)
{
ap_pool_t *pconf = process->pconf;
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)
{
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...
*/
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;
#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...
*/
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");
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...
*/
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");
#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...
*/
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");
}
}
-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)
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;
}
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;
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);
}