]> granicus.if.org Git - apache/commitdiff
Updated the various MPM's to use the new bucket_alloc_create_ex API
authorCliff Woolley <jwoolley@apache.org>
Thu, 28 Aug 2003 05:54:44 +0000 (05:54 +0000)
committerCliff Woolley <jwoolley@apache.org>
Thu, 28 Aug 2003 05:54:44 +0000 (05:54 +0000)
when necessary.  Which is to say that it's necessary in all cases except
for prefork, where the change to apr-util to have it use the allocator
from the pool passed in is already sufficient.

Reviewed by: Jean-Jacques Clar, Sander Striker, Brad Nicholes

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@101122 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/mpm/beos/beos.c
server/mpm/experimental/leader/leader.c
server/mpm/experimental/threadpool/threadpool.c
server/mpm/mpmt_os2/mpmt_os2_child.c
server/mpm/netware/mpm_netware.c
server/mpm/worker/worker.c

diff --git a/CHANGES b/CHANGES
index 6edcddbec26e910d606116913bde8f95fcceb7a8..75fb5ea71919fa54de34b0b219069ca087eb4fd8 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) The bucket brigades subsystem now honors the MaxMemFree setting.
+     [Cliff Woolley, Jean-Jacques Clar]
+
   *) Fix mod_include's expression parser to recognize strings correctly
      even if they start with an escaped token.  [AndrĂ© Malo]
 
index 7e5c15e81f20d72e80784ac1302ca5ce665c64d5..2c68d69eaf0e739cd791375cae4293657bc05df4 100644 (file)
@@ -390,6 +390,8 @@ static int32 worker_thread(void * dummy)
 
     apr_pool_tag(ptrans, "transaction");
 
+    bucket_alloc = apr_bucket_alloc_create_ex(allocator);
+
     apr_thread_mutex_lock(worker_thread_count_mutex);
     worker_thread_count++;
     apr_thread_mutex_unlock(worker_thread_count_mutex);
@@ -400,8 +402,6 @@ static int32 worker_thread(void * dummy)
     apr_poll_setup(&pollset, num_listening_sockets + 1, tpool);
     for(n=0 ; n <= num_listening_sockets ; n++)
         apr_poll_socket_add(pollset, listening_sockets[n], APR_POLLIN);
-       
-    bucket_alloc = apr_bucket_alloc_create(tpool);
 
     while (1) {
         /* If we're here, then chances are (unless we're the first thread created) 
index e427789ab1fa5a600d3d4dbba58071802202d848..f66ae1097121fd3073d44f30cd3b75c6da491299 100644 (file)
@@ -715,9 +715,10 @@ static void *worker_thread(apr_thread_t *thd, void * dummy)
 
     apr_allocator_create(&allocator);
     apr_allocator_max_free_set(allocator, ap_max_mem_free);
+    /* XXX: why is ptrans's parent not tpool?  --jcw 08/2003 */
     apr_pool_create_ex(&ptrans, NULL, NULL, allocator);
     apr_allocator_owner_set(allocator, ptrans);
-    bucket_alloc = apr_bucket_alloc_create(tpool);
+    bucket_alloc = apr_bucket_alloc_create_ex(allocator);
 
     apr_poll_setup(&pollset, num_listensocks, tpool);
     for(lr = ap_listeners ; lr != NULL ; lr = lr->next)
index ca69c00eb2c36b9b04ff6a4a6533111256f53a2e..f4558de44f1f7292b3083e1dd69cfb3b7103b59e 100644 (file)
@@ -981,12 +981,10 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy)
 
     apr_allocator_create(&allocator);
     apr_allocator_max_free_set(allocator, ap_max_mem_free);
+    /* XXX: why is ptrans's parent not tpool? --jcw 08/2003 */
     apr_pool_create_ex(&ptrans, NULL, NULL, allocator);
     apr_allocator_owner_set(allocator, ptrans);
-
-    /* XXX: What happens if this is allocated from the
-     * single-thread-optimized ptrans pool? -aaron */
-    bucket_alloc = apr_bucket_alloc_create(tpool);
+    bucket_alloc = apr_bucket_alloc_create_ex(allocator);
 
     wakeup = (worker_wakeup_info *)apr_palloc(tpool, sizeof(*wakeup));
     wakeup->pool = ptrans;
index fe7fba207ad29124f24e7a6f4a2cff4d36efade8..af55e6de2893d896d7258ae576f101ce3eaed8e2 100644 (file)
@@ -402,6 +402,7 @@ static void worker_main(void *vpArg)
     long conn_id;
     conn_rec *current_conn;
     apr_pool_t *pconn;
+    apr_allocator_t *allocator;
     apr_bucket_alloc_t *bucket_alloc;
     worker_args_t *worker_args;
     HQUEUE workq;
@@ -430,10 +431,13 @@ static void worker_main(void *vpArg)
     ap_update_child_status_from_indexes(child_slot, thread_slot, SERVER_READY, 
                                         NULL);
 
+    apr_allocator_create(&allocator);
+    apr_allocator_max_free_set(allocator, ap_max_mem_free);
+    bucket_alloc = apr_bucket_alloc_create_ex(allocator);
+
     while (rc = DosReadQueue(workq, &rd, &len, (PPVOID)&worker_args, 0, DCWW_WAIT, &priority, NULLHANDLE),
            rc == 0 && rd.ulData != WORKTYPE_EXIT) {
         pconn = worker_args->pconn;
-        bucket_alloc = apr_bucket_alloc_create(pconn);
         ap_create_sb_handle(&sbh, pconn, child_slot, thread_slot);
         current_conn = ap_run_create_connection(pconn, ap_server_conf,
                                                 worker_args->conn_sd, conn_id,
@@ -451,6 +455,9 @@ static void worker_main(void *vpArg)
 
     ap_update_child_status_from_indexes(child_slot, thread_slot, SERVER_DEAD, 
                                         NULL);
+
+    apr_bucket_alloc_destroy(bucket_alloc);
+    apr_allocator_destroy(allocator);
 }
 
 
index b252cf4b716d00a01eacefe5580ce957bb12d4f4..4c206ab42f728c59a60c55b06e80d64abeffc3f5 100644 (file)
@@ -212,14 +212,14 @@ static int volatile wait_to_finish=1;
 ap_generation_t volatile ap_my_generation=0;
 
 /* a clean exit from a child with proper cleanup */
-static void clean_child_exit(int code, int worker_num, apr_pool_t *pthrd
+static void clean_child_exit(int code, int worker_num, apr_pool_t *ptrans
                              apr_bucket_alloc_t *bucket_alloc) __attribute__ ((noreturn));
-static void clean_child_exit(int code, int worker_num, apr_pool_t *pthrd
+static void clean_child_exit(int code, int worker_num, apr_pool_t *ptrans
                              apr_bucket_alloc_t *bucket_alloc)
 {
+    apr_bucket_alloc_destroy(bucket_alloc);
     if (!shutdown_pending) {
-        apr_bucket_alloc_destroy(bucket_alloc);
-        apr_pool_destroy(pthrd);
+        apr_pool_destroy(ptrans);
     }
 
     atomic_dec (&worker_thread_count);
@@ -359,7 +359,7 @@ static int avg_retries = 0;
 void worker_main(void *arg)
 {
     ap_listen_rec *lr, *first_lr, *last_lr = NULL;
-    apr_pool_t *ptrans, *pthrd;
+    apr_pool_t *ptrans;
     apr_pool_t *pbucket;
     apr_allocator_t *allocator;
     apr_bucket_alloc_t *bucket_alloc;
@@ -384,14 +384,11 @@ void worker_main(void *arg)
     apr_allocator_create(&allocator);
     apr_allocator_max_free_set(allocator, ap_max_mem_free);
 
-    apr_pool_create_ex(&pthrd, pmain, NULL, allocator);
-    apr_allocator_owner_set(allocator, pthrd);
-    apr_pool_tag(pthrd, "worker_thrd_pool");
-
-    apr_pool_create(&ptrans, pthrd);
+    apr_pool_create_ex(&ptrans, pmain, NULL, allocator);
+    apr_allocator_owner_set(allocator, ptrans);
     apr_pool_tag(ptrans, "transaction");
 
-    bucket_alloc = apr_bucket_alloc_create(pthrd);
+    bucket_alloc = apr_bucket_alloc_create_ex(allocator);
 
     atomic_inc (&worker_thread_count);
 
@@ -405,7 +402,7 @@ void worker_main(void *arg)
         if ((ap_max_requests_per_child > 0
             && requests_this_child++ >= ap_max_requests_per_child)) {
             DBPRINT1 ("\n**Thread slot %d is shutting down", my_worker_num);
-            clean_child_exit(0, my_worker_num, pthrd, bucket_alloc);
+            clean_child_exit(0, my_worker_num, ptrans, bucket_alloc);
         }
 
         ap_update_child_status_from_indexes(0, my_worker_num, WORKER_READY, 
@@ -418,7 +415,7 @@ void worker_main(void *arg)
         for (;;) {
             if (shutdown_pending || restart_pending || (ap_scoreboard_image->servers[0][my_worker_num].status == WORKER_IDLE_KILL)) {
                 DBPRINT1 ("\nThread slot %d is shutting down\n", my_worker_num);
-                clean_child_exit(0, my_worker_num, pthrd, bucket_alloc);
+                clean_child_exit(0, my_worker_num, ptrans, bucket_alloc);
             }
 
             /* Check the listen queue on all sockets for requests */
@@ -527,13 +524,13 @@ void worker_main(void *arg)
                         */
                         ap_log_error(APLOG_MARK, APLOG_EMERG, stat, ap_server_conf,
                             "apr_accept: giving up.");
-                        clean_child_exit(APEXIT_CHILDFATAL, my_worker_num, pthrd
+                        clean_child_exit(APEXIT_CHILDFATAL, my_worker_num, ptrans
                                          bucket_alloc);
                 }
                 else {
                         ap_log_error(APLOG_MARK, APLOG_ERR, stat, ap_server_conf,
                             "apr_accept: (client socket)");
-                        clean_child_exit(1, my_worker_num, pthrd, bucket_alloc);
+                        clean_child_exit(1, my_worker_num, ptrans, bucket_alloc);
                 }
             }
         }
@@ -552,7 +549,7 @@ void worker_main(void *arg)
         }
         request_count++;
     }
-    clean_child_exit(0, my_worker_num, pthrd, bucket_alloc);
+    clean_child_exit(0, my_worker_num, ptrans, bucket_alloc);
 }
 
 
index 6025bd99a08fec04261958e6f91c91c6955955a6..563c3bcafb94d30a472edde7c33e7ca17706f7d4 100644 (file)
@@ -825,8 +825,6 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy)
 
     ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_STARTING, NULL);
 
-    bucket_alloc = apr_bucket_alloc_create(apr_thread_pool_get(thd));
-
     while (!workers_may_exit) {
         if (!is_idle) {
             rv = ap_queue_info_set_idle(worker_queue_info, last_ptrans);
@@ -878,6 +876,7 @@ worker_pop:
         }
         is_idle = 0;
         worker_sockets[thread_slot] = csd;
+        bucket_alloc = apr_bucket_alloc_create(ptrans);
         process_socket(ptrans, csd, process_slot, thread_slot, bucket_alloc);
         worker_sockets[thread_slot] = NULL;
         requests_this_child--; /* FIXME: should be synchronized - aaron */
@@ -888,8 +887,6 @@ worker_pop:
     ap_update_child_status_from_indexes(process_slot, thread_slot,
         (dying) ? SERVER_DEAD : SERVER_GRACEFUL, (request_rec *) NULL);
 
-    apr_bucket_alloc_destroy(bucket_alloc);
-
     apr_thread_exit(thd, APR_SUCCESS);
     return NULL;
 }