From d6f8c966b0517072156f226955c29122190cc723 Mon Sep 17 00:00:00 2001 From: Colm MacCarthaigh Date: Wed, 24 Aug 2005 16:51:20 +0000 Subject: [PATCH] Provide a function for closing all of the listeners. * This is useful for properly implementing a graceful stop and restart where we want child processess to be able to carry on serving a request but "de-listen" from a port. So that another instance entirely can be started in our place, or to unbind from a "Listen" directive an admin has removed from the configuration. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@239710 13f79535-47bb-0310-9956-ffa450edef68 --- include/ap_listen.h | 5 +++++ server/listen.c | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/ap_listen.h b/include/ap_listen.h index d98949f379..ecff132a37 100644 --- a/include/ap_listen.h +++ b/include/ap_listen.h @@ -77,6 +77,11 @@ AP_DECLARE(void) ap_listen_pre_config(void); */ AP_DECLARE(int) ap_setup_listeners(server_rec *s); +/** + * Loop through the global ap_listen_rec list and close each of the sockets. + */ +AP_DECLARE_NONSTD(void) ap_close_listeners(); + /* Although these functions are exported from libmain, they are not really * public functions. These functions are actually called while parsing the * config file, when one of the LISTEN_COMMANDS directives is read. These diff --git a/server/listen.c b/server/listen.c index 6a3ee9e7bf..15ad6a0ff9 100644 --- a/server/listen.c +++ b/server/listen.c @@ -238,17 +238,10 @@ static void ap_apply_accept_filter(apr_pool_t *p, ap_listen_rec *lis, static apr_status_t close_listeners_on_exec(void *v) { - ap_listen_rec *lr; - - for (lr = ap_listeners; lr; lr = lr->next) { - apr_socket_close(lr->sd); - lr->active = 0; - } - + ap_close_listeners(); return APR_SUCCESS; } - static const char *alloc_listener(process_rec *process, char *addr, apr_port_t port, const char* proto) { @@ -541,6 +534,15 @@ AP_DECLARE(int) ap_setup_listeners(server_rec *s) return num_listeners; } +AP_DECLARE_NONSTD(void) ap_close_listeners() { + ap_listen_rec *lr; + + for (lr = ap_listeners; lr; lr = lr->next) { + apr_socket_close(lr->sd); + lr->active = 0; + } +} + AP_DECLARE(void) ap_listen_pre_config(void) { old_listeners = ap_listeners; -- 2.40.0