From a47ed5762de20d7b67f29ba4d493f07cf8239820 Mon Sep 17 00:00:00 2001 From: Ryan Bloom Date: Tue, 13 Nov 2001 07:15:36 +0000 Subject: This allows modules to add socket descriptors to the pollset. I have only added this to the perfork MPM, and the others work without it. Tomorrow I will add it to the other MPMs. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91899 13f79535-47bb-0310-9956-ffa450edef68 --- include/http_connection.h | 2 ++ server/connection.c | 4 ++++ server/core.c | 14 ++++++++++++++ server/mpm/prefork/prefork.c | 10 +++------- 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) { /* -- cgit v1.2.3