From: Stefan Fritsch Date: Tue, 29 Sep 2015 20:16:47 +0000 (+0000) Subject: When shutting down a process, free resources early X-Git-Tag: 2.5.0-alpha~2786 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1cd56c513131ff404afa6e28ade46e53b9b43a9;p=thirdparty%2Fapache%2Fhttpd.git When shutting down a process, free resources early Due to lingering connections, shutting down a process may take a very long time. Free all recycled pools early in the hope that we can already give some memory back to the OS. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1705922 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index c37d6f98bc2..1f3e186c453 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mpm_event: Free memory earlier when shutting down processes. + [Stefan Fritsch] + *) mod_ssl: Make the output filter more friendly with deferred write and response pipelining. [Yann Ylavic, Joe Orton] diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 7ba911ef052..2b09c215c82 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -1282,6 +1282,8 @@ static void close_listeners(int process_slot, int *closed) } /* wake up the main thread */ kill(ap_my_pid, SIGTERM); + + ap_free_idle_pools(worker_queue_info); } } diff --git a/server/mpm/event/fdqueue.c b/server/mpm/event/fdqueue.c index e78174f05e7..75b79047b22 100644 --- a/server/mpm/event/fdqueue.c +++ b/server/mpm/event/fdqueue.c @@ -277,6 +277,19 @@ void ap_pop_pool(apr_pool_t ** recycled_pool, fd_queue_info_t * queue_info) } } +void ap_free_idle_pools(fd_queue_info_t *queue_info) +{ + apr_pool_t *p; + + queue_info->max_recycled_pools = 0; + do { + ap_pop_pool(&p, queue_info); + if (p != NULL) + apr_pool_destroy(p); + } while (p != NULL); +} + + apr_status_t ap_queue_info_term(fd_queue_info_t * queue_info) { apr_status_t rv; diff --git a/server/mpm/event/fdqueue.h b/server/mpm/event/fdqueue.h index 2d9134a5fbd..1e5a4e4c6ca 100644 --- a/server/mpm/event/fdqueue.h +++ b/server/mpm/event/fdqueue.h @@ -52,6 +52,7 @@ apr_status_t ap_queue_info_wait_for_idler(fd_queue_info_t * queue_info, int *had_to_block); apr_status_t ap_queue_info_term(fd_queue_info_t * queue_info); apr_uint32_t ap_queue_info_get_idlers(fd_queue_info_t * queue_info); +void ap_free_idle_pools(fd_queue_info_t *queue_info); struct fd_queue_elem_t {