Commit 387a2feb authored by Colm MacCarthaigh's avatar Colm MacCarthaigh
Browse files

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
parent 75e35ed3
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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
+10 −8
Original line number Diff line number Diff line
@@ -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;