summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/http_connection.h2
-rw-r--r--server/connection.c4
-rw-r--r--server/core.c14
-rw-r--r--server/mpm/prefork/prefork.c10
4 files changed, 23 insertions, 7 deletions
diff --git a/include/http_connection.h b/include/http_connection.h
index 3a61963771..53cb0a9675 100644
--- a/include/http_connection.h
+++ b/include/http_connection.h
@@ -143,6 +143,8 @@ AP_DECLARE_HOOK(int,process_connection,(conn_rec *c))
AP_DECLARE_HOOK(conn_rec *, create_connection,
(apr_pool_t *p, apr_socket_t *csd, int conn_id))
+AP_DECLARE_HOOK(int, add_listeners, (apr_pollfd_t *pollset, apr_socket_t **listensocks, int num_listensocks))
+
#ifdef __cplusplus
}
#endif
diff --git a/server/connection.c b/server/connection.c
index 2d379d2063..a7c2a3864b 100644
--- a/server/connection.c
+++ b/server/connection.c
@@ -76,9 +76,13 @@
APR_HOOK_STRUCT(
APR_HOOK_LINK(pre_connection)
APR_HOOK_LINK(process_connection)
+ APR_HOOK_LINK(add_listeners)
APR_HOOK_LINK(create_connection)
)
+AP_IMPLEMENT_HOOK_RUN_ALL(int,add_listeners,
+ (apr_pollfd_t *pollset, apr_socket_t **listensocks, int num_listensocks),
+ (pollset, listensocks, num_listensocks),OK,DECLINED)
AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c),(c),OK,DECLINED)
AP_IMPLEMENT_HOOK_RUN_FIRST(int,process_connection,(conn_rec *c),(c),DECLINED)
AP_IMPLEMENT_HOOK_RUN_FIRST(conn_rec *,create_connection,
diff --git a/server/core.c b/server/core.c
index 84ad3b1b7f..7764eb48f8 100644
--- a/server/core.c
+++ b/server/core.c
@@ -3329,6 +3329,19 @@ static conn_rec *core_create_conn(apr_pool_t *ptrans, apr_socket_t *csd,
return net->c;
}
+static int core_add_listeners(apr_pollfd_t *pollset,
+ apr_socket_t **listensocks, int num_listensocks)
+{
+ int i;
+ ap_listen_rec *lr;
+
+ for (lr = ap_listeners, i = 0; i < num_listensocks; lr = lr->next, i++) {
+ listensocks[i] = lr->sd;
+ apr_poll_socket_add(pollset, listensocks[i], APR_POLLIN);
+ }
+ return OK;
+}
+
static void register_hooks(apr_pool_t *p)
{
ap_hook_post_config(core_post_config,NULL,NULL,APR_HOOK_REALLY_FIRST);
@@ -3342,6 +3355,7 @@ static void register_hooks(apr_pool_t *p)
ap_hook_access_checker(do_nothing,NULL,NULL,APR_HOOK_REALLY_LAST);
ap_hook_create_connection(core_create_conn, NULL, NULL, APR_HOOK_REALLY_LAST);
ap_hook_create_request(core_create_req, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_add_listeners(core_add_listeners, NULL, NULL, APR_HOOK_MIDDLE);
APR_OPTIONAL_HOOK(proxy, create_req, core_create_proxy_req, NULL, NULL,
APR_HOOK_MIDDLE);
ap_hook_pre_mpm(ap_create_scoreboard, NULL, NULL, APR_HOOK_MIDDLE);
diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c
index 913c61f025..9c26e1bc8a 100644
--- a/server/mpm/prefork/prefork.c
+++ b/server/mpm/prefork/prefork.c
@@ -544,8 +544,7 @@ static void child_main(int child_num_arg)
apr_pool_t *ptrans;
conn_rec *current_conn;
apr_status_t stat = APR_EINIT;
- int sockdes, i;
- ap_listen_rec *lr;
+ int sockdes;
int curr_pollfd, last_pollfd = 0;
apr_pollfd_t *pollset;
apr_socket_t *sd;
@@ -576,15 +575,12 @@ static void child_main(int child_num_arg)
ap_sync_scoreboard_image();
+ apr_poll_setup(&pollset, num_listensocks, pchild);
/* Set up the pollfd array */
listensocks = apr_pcalloc(pchild,
sizeof(*listensocks) * (num_listensocks));
- for (lr = ap_listeners, i = 0; i < num_listensocks; lr = lr->next, i++)
- listensocks[i]=lr->sd;
- apr_poll_setup(&pollset, num_listensocks, pchild);
- for (i = 0; i < num_listensocks; i++)
- apr_poll_socket_add(pollset, listensocks[i], APR_POLLIN);
+ ap_run_add_listeners(pollset, listensocks, num_listensocks);
while (!die_now) {
/*