]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
task bucket_alloc now created per task pool, spare pools properly destroyed
authorStefan Eissing <icing@apache.org>
Mon, 9 Nov 2015 16:18:52 +0000 (16:18 +0000)
committerStefan Eissing <icing@apache.org>
Mon, 9 Nov 2015 16:18:52 +0000 (16:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1713472 13f79535-47bb-0310-9956-ffa450edef68

modules/http2/h2_conn.c
modules/http2/h2_conn.h
modules/http2/h2_mplx.c
modules/http2/h2_session.c
modules/http2/h2_task.c
modules/http2/h2_worker.c
modules/http2/h2_worker.h

index f1fcbffb8088c6e9a111b08b121246b6b8341da0..15dca277757f34c4cf5f5e9c3c0b843183c2ea3d 100644 (file)
@@ -248,7 +248,8 @@ conn_rec *h2_conn_create(conn_rec *master, apr_pool_t *pool)
     return c;
 }
 
-apr_status_t h2_conn_setup(h2_task *task, struct h2_worker *worker)
+apr_status_t h2_conn_setup(h2_task *task, apr_bucket_alloc_t *bucket_alloc,
+                           apr_thread_t *thread, apr_socket_t *socket)
 {
     conn_rec *master = task->mplx->c;
     
@@ -262,8 +263,8 @@ apr_status_t h2_conn_setup(h2_task *task, struct h2_worker *worker)
      * pools.
      */
     task->c->pool = task->pool;
-    task->c->bucket_alloc = h2_worker_get_bucket_alloc(worker);
-    task->c->current_thread = h2_worker_get_thread(worker);
+    task->c->current_thread = thread;
+    task->c->bucket_alloc = bucket_alloc;
     
     task->c->conn_config = ap_create_conn_config(task->pool);
     task->c->notes = apr_table_make(task->pool, 5);
@@ -271,8 +272,7 @@ apr_status_t h2_conn_setup(h2_task *task, struct h2_worker *worker)
     /* In order to do this in 2.4.x, we need to add a member to conn_rec */
     task->c->master = master;
     
-    ap_set_module_config(task->c->conn_config, &core_module, 
-                         h2_worker_get_socket(worker));
+    ap_set_module_config(task->c->conn_config, &core_module, socket);
     
     /* This works for mpm_worker so far. Other mpm modules have 
      * different needs, unfortunately. The most interesting one 
index 88caf1710d5c230a28ef04b11d0f5a45c740b8d3..84cf8d83c407e2f6164e9a68935500c0e972f5fc 100644 (file)
@@ -17,7 +17,6 @@
 #define __mod_h2__h2_conn__
 
 struct h2_task;
-struct h2_worker;
 
 /**
  * Process the connection that is now starting the HTTP/2
@@ -49,6 +48,7 @@ h2_mpm_type_t h2_conn_mpm_type(void);
 
 conn_rec *h2_conn_create(conn_rec *master, apr_pool_t *stream_pool);
 
-apr_status_t h2_conn_setup(struct h2_task *task, struct h2_worker *worker);
+apr_status_t h2_conn_setup(struct h2_task *task, apr_bucket_alloc_t *bucket_alloc,
+                           apr_thread_t *thread, apr_socket_t *socket);
 
 #endif /* defined(__mod_h2__h2_conn__) */
index 11cfd5c8082ddd6e2c240eefe03d0473b93882ba..7d052c53ea30147d7c1311c5b98197cba25e306f 100644 (file)
@@ -74,6 +74,10 @@ static void h2_mplx_destroy(h2_mplx *m)
         m->lock = NULL;
     }
     
+    if (m->spare_pool) {
+        apr_pool_destroy(m->spare_pool);
+        m->spare_pool = NULL;
+    }
     if (m->pool) {
         apr_pool_destroy(m->pool);
     }
index 1ccfaa26ade20ac1d25b43ddcb551fbbd78409fe..2e93a66cc518607051bb204e285343a941cf63f2 100644 (file)
@@ -780,14 +780,20 @@ void h2_session_destroy(h2_session *session)
         nghttp2_session_del(session->ngh2);
         session->ngh2 = NULL;
     }
+    if (session->spare) {
+        apr_pool_destroy(session->spare);
+        session->spare = NULL;
+    }
+    if (session->pool) {
+        apr_pool_destroy(session->pool);
+    }
 }
 
 void h2_session_cleanup(h2_session *session)
 {
+    ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
+                  "session(%ld): cleanup and destroy", session->id);
     h2_session_destroy(session);
-    if (session->pool) {
-        apr_pool_destroy(session->pool);
-    }
 }
 
 static apr_status_t h2_session_abort_int(h2_session *session, int reason)
index 1d95496d2d19d7031e2dbb15c8b6afa96e665395..f0f024a0dcc360fba5d8fb7174f06e3614ff8218 100644 (file)
@@ -206,17 +206,8 @@ apr_status_t h2_task_do(h2_task *task, h2_worker *worker)
     AP_DEBUG_ASSERT(task);
     
     task->serialize_headers = h2_config_geti(cfg, H2_CONF_SER_HEADERS);
-    
-    /* Create a subpool from the worker one to be used for all things
-     * with life-time of this task execution.
-     */
-    apr_pool_create(&task->pool, h2_worker_get_pool(worker));
 
-    /* Link the task to the worker which provides useful things such
-     * as mutex, a socket etc. */
-    task->io = h2_worker_get_cond(worker);
-    
-    status = h2_conn_setup(task, worker);
+    status = h2_worker_setup_task(worker, task);
     
     /* save in connection that this one is a pseudo connection, prevents
      * other hooks from messing with it. */
@@ -252,10 +243,7 @@ apr_status_t h2_task_do(h2_task *task, h2_worker *worker)
         apr_thread_cond_signal(task->io);
     }
     
-    if (task->pool) {
-        apr_pool_destroy(task->pool);
-        task->pool = NULL;
-    }
+    h2_worker_release_task(worker, task);
     
     h2_mplx_task_done(task->mplx, task->stream_id);
     
index 297b4b21fe6be1198ecbf2a8a153eb85c9d3bfd7..010042137128c429060cd0c6ffd4af70dd8884be 100644 (file)
@@ -22,6 +22,7 @@
 #include <http_log.h>
 
 #include "h2_private.h"
+#include "h2_conn.h"
 #include "h2_mplx.h"
 #include "h2_task.h"
 #include "h2_worker.h"
@@ -55,7 +56,7 @@ static void* APR_THREAD_FUNC execute(apr_thread_t *thread, void *wctx)
         if (worker->task) {            
             h2_task_do(worker->task, worker);
             worker->task = NULL;
-            apr_thread_cond_signal(h2_worker_get_cond(worker));
+            apr_thread_cond_signal(worker->io);
         }
     }
 
@@ -112,7 +113,6 @@ h2_worker *h2_worker_create(int id,
         
         w->id = id;
         w->pool = pool;
-        w->bucket_alloc = apr_bucket_alloc_create(pool);
 
         w->get_next = get_next;
         w->worker_done = worker_done;
@@ -157,14 +157,32 @@ int h2_worker_is_aborted(h2_worker *worker)
     return worker->aborted;
 }
 
-apr_thread_t *h2_worker_get_thread(h2_worker *worker)
-{
-    return worker->thread;
+apr_status_t h2_worker_setup_task(h2_worker *worker, h2_task *task) {
+    apr_status_t status;
+    
+    /* Create a subpool from the worker one to be used for all things
+     * with life-time of this task execution.
+     */
+    apr_pool_create(&task->pool, worker->pool);
+
+    /* Link the task to the worker which provides useful things such
+     * as mutex, a socket etc. */
+    task->io = worker->io;
+    
+    status = h2_conn_setup(task, apr_bucket_alloc_create(task->pool),
+                           worker->thread, worker->socket);
+    
+    return status;
 }
 
-apr_thread_cond_t *h2_worker_get_cond(h2_worker *worker)
+void h2_worker_release_task(h2_worker *worker, struct h2_task *task)
 {
-    return worker->io;
+    task->io = NULL;
+    
+    if (task->pool) {
+        apr_pool_destroy(task->pool);
+        task->pool = NULL;
+    }
 }
 
 apr_socket_t *h2_worker_get_socket(h2_worker *worker)
@@ -172,13 +190,4 @@ apr_socket_t *h2_worker_get_socket(h2_worker *worker)
     return worker->socket;
 }
 
-apr_pool_t *h2_worker_get_pool(h2_worker *worker)
-{
-    return worker->pool;
-}
-
-apr_bucket_alloc_t *h2_worker_get_bucket_alloc(h2_worker *worker)
-{
-    return worker->bucket_alloc;
-}
 
index 9c69e6b57a8cff8faaab950a119495549acc4a39..ce934f745b2b1b1954842f97db293973359171f9 100644 (file)
@@ -44,7 +44,6 @@ struct h2_worker {
     int id;
     apr_thread_t *thread;
     apr_pool_t *pool;
-    apr_bucket_alloc_t *bucket_alloc;
     struct apr_thread_cond_t *io;
     apr_socket_t *socket;
     
@@ -142,14 +141,9 @@ int h2_worker_get_id(h2_worker *worker);
 
 int h2_worker_is_aborted(h2_worker *worker);
 
-apr_pool_t *h2_worker_get_pool(h2_worker *worker);
-
-apr_bucket_alloc_t *h2_worker_get_bucket_alloc(h2_worker *worker);
+apr_status_t h2_worker_setup_task(h2_worker *worker, struct h2_task *task);
+void h2_worker_release_task(h2_worker *worker, struct h2_task *task);
 
 apr_socket_t *h2_worker_get_socket(h2_worker *worker);
 
-apr_thread_t *h2_worker_get_thread(h2_worker *worker);
-
-struct apr_thread_cond_t *h2_worker_get_cond(h2_worker *worker);
-
 #endif /* defined(__mod_h2__h2_worker__) */