]> granicus.if.org Git - apache/commitdiff
When shutting down a process, free resources early
authorStefan Fritsch <sf@apache.org>
Tue, 29 Sep 2015 20:16:47 +0000 (20:16 +0000)
committerStefan Fritsch <sf@apache.org>
Tue, 29 Sep 2015 20:16:47 +0000 (20:16 +0000)
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

CHANGES
server/mpm/event/event.c
server/mpm/event/fdqueue.c
server/mpm/event/fdqueue.h

diff --git a/CHANGES b/CHANGES
index c37d6f98bc231fa97157faf4c97c0fbc95df9b06..1f3e186c45340af49753d94c6e31659da09ad34a 100644 (file)
--- 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]
 
index 7ba911ef05259c5b1bec95bc95819b6ed6ea5126..2b09c215c82c268a337dc7f1d9d781df86a0a8c6 100644 (file)
@@ -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);
     }
 }
 
index e78174f05e772148cb7b3befd40a0fc06c75460b..75b79047b227e8cd92ed800dde572bd130f4c373 100644 (file)
@@ -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;
index 2d9134a5fbdde5b9f450a1e4772c918b3afc8ece..1e5a4e4c6cae4b9d668622ce69a7a994c44e45d9 100644 (file)
@@ -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
 {