You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2015/12/23 14:04:41 UTC

svn commit: r1721540 - /httpd/httpd/trunk/modules/http2/

Author: icing
Date: Wed Dec 23 13:04:40 2015
New Revision: 1721540

URL: http://svn.apache.org/viewvc?rev=1721540&view=rev
Log:
fixed bug in upload that triggered window_updates during session shutdown, disentanglement of worker, task and request, code cleanups

Modified:
    httpd/httpd/trunk/modules/http2/h2_conn.c
    httpd/httpd/trunk/modules/http2/h2_conn.h
    httpd/httpd/trunk/modules/http2/h2_h2.c
    httpd/httpd/trunk/modules/http2/h2_io.c
    httpd/httpd/trunk/modules/http2/h2_io.h
    httpd/httpd/trunk/modules/http2/h2_mplx.c
    httpd/httpd/trunk/modules/http2/h2_mplx.h
    httpd/httpd/trunk/modules/http2/h2_request.h
    httpd/httpd/trunk/modules/http2/h2_session.c
    httpd/httpd/trunk/modules/http2/h2_stream.c
    httpd/httpd/trunk/modules/http2/h2_task.c
    httpd/httpd/trunk/modules/http2/h2_task.h
    httpd/httpd/trunk/modules/http2/h2_task_input.c
    httpd/httpd/trunk/modules/http2/h2_version.h
    httpd/httpd/trunk/modules/http2/h2_worker.c
    httpd/httpd/trunk/modules/http2/h2_worker.h
    httpd/httpd/trunk/modules/http2/h2_workers.c
    httpd/httpd/trunk/modules/http2/h2_workers.h

Modified: httpd/httpd/trunk/modules/http2/h2_conn.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_conn.c?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_conn.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_conn.c Wed Dec 23 13:04:40 2015
@@ -204,58 +204,53 @@ apr_status_t h2_conn_run(struct h2_ctx *
 
 static void fix_event_conn(conn_rec *c, conn_rec *master);
 
-conn_rec *h2_conn_create(conn_rec *master, apr_pool_t *pool)
+conn_rec *h2_slave_create(conn_rec *master, apr_pool_t *p, 
+                          apr_thread_t *thread, apr_socket_t *socket)
 {
     conn_rec *c;
     
     AP_DEBUG_ASSERT(master);
-
+    ap_log_cerror(APLOG_MARK, APLOG_TRACE3, 0, master,
+                  "h2_conn(%ld): created from master", master->id);
+    
     /* This is like the slave connection creation from 2.5-DEV. A
      * very efficient way - not sure how compatible this is, since
      * the core hooks are no longer run.
      * But maybe it's is better this way, not sure yet.
      */
-    c = (conn_rec *) apr_palloc(pool, sizeof(conn_rec));
+    c = (conn_rec *) apr_palloc(p, sizeof(conn_rec));
     if (c == NULL) {
-        ap_log_perror(APLOG_MARK, APLOG_ERR, APR_ENOMEM, pool, 
+        ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_ENOMEM, master, 
                       APLOGNO(02913) "h2_task: creating conn");
         return NULL;
     }
     
     memcpy(c, master, sizeof(conn_rec));
-    c->id = (master->id & (long)pool);
-    c->master = master;
-    c->input_filters = NULL;
-    c->output_filters = NULL;
-    c->pool = pool;        
-    return c;
-}
-
-apr_status_t h2_slave_setup(h2_task *task, apr_bucket_alloc_t *bucket_alloc,
-                            apr_thread_t *thread, apr_socket_t *socket)
-{
-    conn_rec *master = task->mplx->c;
+           
+    /* Replace these */
+    c->id                     = (master->id & (long)p);
+    c->master                 = master;
+    c->pool                   = p;        
+    c->current_thread         = thread;
+    c->conn_config            = ap_create_conn_config(p);
+    c->notes                  = apr_table_make(p, 5);
+    c->input_filters          = NULL;
+    c->output_filters         = NULL;
+    c->bucket_alloc           = apr_bucket_alloc_create(p);
+    c->cs                     = NULL;
+    c->data_in_input_filters  = 0;
+    c->data_in_output_filters = 0;
+    c->clogging_input_filters = 1;
+    c->log                    = NULL;
+    c->log_id                 = NULL;
     
-    ap_log_perror(APLOG_MARK, APLOG_TRACE3, 0, task->pool,
-                  "h2_conn(%ld): created from master", master->id);
+    /* TODO: these should be unique to this thread */
+    c->sbh                    = master->sbh;
     
-    /* Ok, we are just about to start processing the connection and
-     * the worker is calling us to setup all necessary resources.
-     * We can borrow some from the worker itself and some we do as
-     * sub-resources from it, so that we get a nice reuse of
-     * pools.
-     */
-    task->c->pool = task->pool;
-    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);
-    
-    /* In order to do this in 2.4.x, we need to add a member to conn_rec */
-    task->c->master = master;
+    /* Simulate that we had already a request on this connection. */
+    c->keepalives             = 1;
     
-    ap_set_module_config(task->c->conn_config, &core_module, socket);
+    ap_set_module_config(c->conn_config, &core_module, socket);
     
     /* This works for mpm_worker so far. Other mpm modules have 
      * different needs, unfortunately. The most interesting one 
@@ -266,17 +261,14 @@ apr_status_t h2_slave_setup(h2_task *tas
             /* all fine */
             break;
         case H2_MPM_EVENT: 
-            fix_event_conn(task->c, master);
+            fix_event_conn(c, master);
             break;
         default:
             /* fingers crossed */
             break;
     }
     
-    /* Simulate that we had already a request on this connection. */
-    task->c->keepalives = 1;
-    
-    return APR_SUCCESS;
+    return c;
 }
 
 /* This is an internal mpm event.c struct which is disguised

Modified: httpd/httpd/trunk/modules/http2/h2_conn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_conn.h?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_conn.h (original)
+++ httpd/httpd/trunk/modules/http2/h2_conn.h Wed Dec 23 13:04:40 2015
@@ -56,9 +56,7 @@ typedef enum {
 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_slave_setup(struct h2_task *task, apr_bucket_alloc_t *bucket_alloc,
-                            apr_thread_t *thread, apr_socket_t *socket);
+conn_rec *h2_slave_create(conn_rec *master, apr_pool_t *p, 
+                          apr_thread_t *thread, apr_socket_t *socket);
 
 #endif /* defined(__mod_h2__h2_conn__) */

Modified: httpd/httpd/trunk/modules/http2/h2_h2.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_h2.c?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_h2.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_h2.c Wed Dec 23 13:04:40 2015
@@ -673,7 +673,7 @@ static int h2_h2_post_read_req(request_r
             /* setup the correct output filters to process the response
              * on the proper mod_http2 way. */
             ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r, "adding task output filter");
-            if (task->serialize_headers) {
+            if (task->ser_headers) {
                 ap_add_output_filter("H1_TO_H2_RESP", task, r, r->connection);
             }
             else {

Modified: httpd/httpd/trunk/modules/http2/h2_io.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_io.c?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_io.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_io.c Wed Dec 23 13:04:40 2015
@@ -32,13 +32,13 @@
 #include "h2_task.h"
 #include "h2_util.h"
 
-h2_io *h2_io_create(int id, apr_pool_t *pool, apr_bucket_alloc_t *bucket_alloc)
+h2_io *h2_io_create(int id, apr_pool_t *pool)
 {
     h2_io *io = apr_pcalloc(pool, sizeof(*io));
     if (io) {
         io->id = id;
         io->pool = pool;
-        io->bucket_alloc = bucket_alloc;
+        io->bucket_alloc = apr_bucket_alloc_create(pool);
     }
     return io;
 }

Modified: httpd/httpd/trunk/modules/http2/h2_io.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_io.h?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_io.h (original)
+++ httpd/httpd/trunk/modules/http2/h2_io.h Wed Dec 23 13:04:40 2015
@@ -71,7 +71,7 @@ struct h2_io {
 /**
  * Creates a new h2_io for the given stream id. 
  */
-h2_io *h2_io_create(int id, apr_pool_t *pool, apr_bucket_alloc_t *bucket_alloc);
+h2_io *h2_io_create(int id, apr_pool_t *pool);
 
 /**
  * Frees any resources hold by the h2_io instance. 

Modified: httpd/httpd/trunk/modules/http2/h2_mplx.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_mplx.c?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_mplx.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_mplx.c Wed Dec 23 13:04:40 2015
@@ -136,8 +136,6 @@ h2_mplx *h2_mplx_create(conn_rec *c, apr
             return NULL;
         }
         
-        m->bucket_alloc = apr_bucket_alloc_create(m->pool);
-        
         m->q = h2_tq_create(m->pool, h2_config_geti(conf, H2_CONF_MAX_STREAMS));
         m->stream_ios = h2_io_set_create(m->pool);
         m->ready_ios = h2_io_set_create(m->pool);
@@ -266,6 +264,8 @@ apr_status_t h2_mplx_release_and_join(h2
     workers_unregister(m);
     status = apr_thread_mutex_lock(m->lock);
     if (APR_SUCCESS == status) {
+        /* disable WINDOW_UPDATE callbacks */
+        h2_mplx_set_consumed_cb(m, NULL, NULL);
         while (!h2_io_set_iter(m->stream_ios, stream_done_iter, m)) {
             /* iterator until all h2_io have been orphaned or destroyed */
         }
@@ -901,15 +901,14 @@ static h2_io *open_io(h2_mplx *m, int st
         m->spare_pool = NULL;
     }
     
-    io = h2_io_create(stream_id, io_pool, m->bucket_alloc);
+    io = h2_io_create(stream_id, io_pool);
     h2_io_set_add(m->stream_ios, io);
     
     return io;
 }
 
 
-apr_status_t h2_mplx_process(h2_mplx *m, int stream_id,
-                             const h2_request *req, int eos, 
+apr_status_t h2_mplx_process(h2_mplx *m, int stream_id, const h2_request *req, 
                              h2_stream_pri_cmp *cmp, void *ctx)
 {
     apr_status_t status;
@@ -922,9 +921,8 @@ apr_status_t h2_mplx_process(h2_mplx *m,
     if (APR_SUCCESS == status) {
         h2_io *io = open_io(m, stream_id);
         io->request = req;
-        io->request_body = !eos;
 
-        if (eos) {
+        if (!io->request->body) {
             status = h2_io_in_close(io);
         }
         
@@ -942,9 +940,9 @@ apr_status_t h2_mplx_process(h2_mplx *m,
     return status;
 }
 
-h2_task *h2_mplx_pop_task(h2_mplx *m, h2_worker *w, int *has_more)
+const h2_request *h2_mplx_pop_request(h2_mplx *m, int *has_more)
 {
-    h2_task *task = NULL;
+    const h2_request *req = NULL;
     apr_status_t status;
     
     AP_DEBUG_ASSERT(m);
@@ -955,18 +953,15 @@ h2_task *h2_mplx_pop_task(h2_mplx *m, h2
     status = apr_thread_mutex_lock(m->lock);
     if (APR_SUCCESS == status) {
         int sid;
-        while (!task && (sid = h2_tq_shift(m->q)) > 0) {
-            /* Anything not already setup correctly in the task
-             * needs to be so now, as task will be executed right about 
-             * when this method returns. */
+        while (!req && (sid = h2_tq_shift(m->q)) > 0) {
             h2_io *io = h2_io_set_get(m->stream_ios, sid);
             if (io) {
-                task = h2_worker_create_task(w, m, io->request, !io->request_body);
+                req = io->request;
             }
         }
         *has_more = !h2_tq_empty(m->q);
         apr_thread_mutex_unlock(m->lock);
     }
-    return task;
+    return req;
 }
 

Modified: httpd/httpd/trunk/modules/http2/h2_mplx.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_mplx.h?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_mplx.h (original)
+++ httpd/httpd/trunk/modules/http2/h2_mplx.h Wed Dec 23 13:04:40 2015
@@ -44,7 +44,6 @@ struct h2_stream;
 struct h2_request;
 struct h2_io_set;
 struct apr_thread_cond_t;
-struct h2_worker;
 struct h2_workers;
 struct h2_stream_set;
 struct h2_task_queue;
@@ -65,7 +64,6 @@ struct h2_mplx {
     volatile int refs;
     conn_rec *c;
     apr_pool_t *pool;
-    apr_bucket_alloc_t *bucket_alloc;
 
     unsigned int aborted : 1;
 
@@ -165,12 +163,10 @@ apr_status_t h2_mplx_out_trywait(h2_mplx
  * @param m the multiplexer
  * @param stream_id the identifier of the stream
  * @param r the request to be processed
- * @param eos if input is complete
  * @param cmp the stream priority compare function
  * @param ctx context data for the compare function
  */
-apr_status_t h2_mplx_process(h2_mplx *m, int stream_id,
-                             const struct h2_request *r, int eos, 
+apr_status_t h2_mplx_process(h2_mplx *m, int stream_id, const struct h2_request *r, 
                              h2_stream_pri_cmp *cmp, void *ctx);
 
 /**
@@ -182,7 +178,7 @@ apr_status_t h2_mplx_process(h2_mplx *m,
  */
 apr_status_t h2_mplx_reprioritize(h2_mplx *m, h2_stream_pri_cmp *cmp, void *ctx);
 
-struct h2_task *h2_mplx_pop_task(h2_mplx *mplx, struct h2_worker *w, int *has_more);
+const struct h2_request *h2_mplx_pop_request(h2_mplx *mplx, int *has_more);
 
 /**
  * Register a callback for the amount of input data consumed per stream. The

Modified: httpd/httpd/trunk/modules/http2/h2_request.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_request.h?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_request.h (original)
+++ httpd/httpd/trunk/modules/http2/h2_request.h Wed Dec 23 13:04:40 2015
@@ -43,6 +43,7 @@ struct h2_request {
     
     unsigned int chunked : 1; /* iff requst body needs to be forwarded as chunked */
     unsigned int eoh     : 1; /* iff end-of-headers has been seen and request is complete */
+    unsigned int body    : 1; /* iff this request has a body */
     unsigned int push    : 1; /* iff server push is possible for this request */
     
     const struct h2_config *config;

Modified: httpd/httpd/trunk/modules/http2/h2_session.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_session.c?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_session.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_session.c Wed Dec 23 13:04:40 2015
@@ -684,6 +684,7 @@ static void h2_session_destroy(h2_sessio
                       session->id, (int)h2_stream_set_size(session->streams));
     }
     if (session->mplx) {
+        h2_mplx_set_consumed_cb(session->mplx, NULL, NULL);
         h2_mplx_release_and_join(session->mplx, session->iowait);
         session->mplx = NULL;
     }

Modified: httpd/httpd/trunk/modules/http2/h2_stream.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_stream.c?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_stream.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_stream.c Wed Dec 23 13:04:40 2015
@@ -298,13 +298,14 @@ apr_status_t h2_stream_schedule(h2_strea
                                     eos, push_enabled);
     if (status == APR_SUCCESS) {
         if (!eos) {
+            stream->request->body = 1;
             stream->bbin = apr_brigade_create(stream->pool, 
                                               stream->session->c->bucket_alloc);
         }
         stream->input_remaining = stream->request->content_length;
         
         status = h2_mplx_process(stream->session->mplx, stream->id, 
-                                 stream->request, eos, cmp, ctx);
+                                 stream->request, cmp, ctx);
         stream->scheduled = 1;
         
         ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c,

Modified: httpd/httpd/trunk/modules/http2/h2_task.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_task.c?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_task.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_task.c Wed Dec 23 13:04:40 2015
@@ -143,9 +143,9 @@ static int h2_task_pre_conn(conn_rec* c,
 }
 
 h2_task *h2_task_create(long session_id, const h2_request *req, 
-                        apr_pool_t *pool, h2_mplx *mplx, int eos)
+                        apr_pool_t *pool, h2_mplx *mplx)
 {
-    h2_task *task = apr_pcalloc(pool, sizeof(h2_task));
+    h2_task *task     = apr_pcalloc(pool, sizeof(h2_task));
     if (task == NULL) {
         ap_log_perror(APLOG_MARK, APLOG_ERR, APR_ENOMEM, pool,
                       APLOGNO(02941) "h2_task(%ld-%d): create stream task", 
@@ -154,72 +154,35 @@ h2_task *h2_task_create(long session_id,
         return NULL;
     }
     
-    task->id        = apr_psprintf(pool, "%ld-%d", session_id, req->id);
-    task->stream_id = req->id;
-    task->pool      = pool;
-    task->mplx      = mplx;
-    task->c         = h2_conn_create(mplx->c, task->pool);
+    task->id          = apr_psprintf(pool, "%ld-%d", session_id, req->id);
+    task->stream_id   = req->id;
+    task->mplx        = mplx;
+    task->request     = req;
+    task->input_eos   = !req->body;
+    task->ser_headers = h2_config_geti(req->config, H2_CONF_SER_HEADERS);
 
-    task->request   = req;
-    task->input_eos = eos;    
-    
     return task;
 }
 
-apr_status_t h2_task_destroy(h2_task *task)
-{
-    (void)task;
-    return APR_SUCCESS;
-}
-
-apr_status_t h2_task_do(h2_task *task, h2_worker *worker)
+apr_status_t h2_task_do(h2_task *task, conn_rec *c, apr_thread_cond_t *cond, 
+                        apr_socket_t *socket)
 {
-    apr_status_t status = APR_SUCCESS;
-    
     AP_DEBUG_ASSERT(task);
+    task->io = cond;
+    task->input = h2_task_input_create(task, c->pool, c->bucket_alloc);
+    task->output = h2_task_output_create(task, c->pool);
+    
+    ap_process_connection(c, socket);
+    
+    ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c,
+                  "h2_task(%s): processing done", task->id);
+    
+    h2_task_input_destroy(task->input);
+    h2_task_output_close(task->output);
+    h2_task_output_destroy(task->output);
+    task->io = NULL;
     
-    task->serialize_headers = h2_config_geti(task->request->config, H2_CONF_SER_HEADERS);
-
-    status = h2_worker_setup_task(worker, task);
-    
-    /* save in connection that this one is a pseudo connection */
-    h2_ctx_create_for(task->c, task);
-
-    if (status == APR_SUCCESS) {
-        task->input = h2_task_input_create(task, task->pool, 
-                                           task->c->bucket_alloc);
-        task->output = h2_task_output_create(task, task->pool);
-        
-        ap_process_connection(task->c, h2_worker_get_socket(worker));
-        
-        ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, task->c,
-                      "h2_task(%s): processing done", task->id);
-    }
-    else {
-        ap_log_cerror(APLOG_MARK, APLOG_WARNING, status, task->c,
-                      APLOGNO(02957) "h2_task(%s): error setting up h2_task", 
-                      task->id);
-    }
-    
-    if (task->input) {
-        h2_task_input_destroy(task->input);
-        task->input = NULL;
-    }
-    
-    if (task->output) {
-        h2_task_output_close(task->output);
-        h2_task_output_destroy(task->output);
-        task->output = NULL;
-    }
-
-    if (task->io) {
-        apr_thread_cond_signal(task->io);
-    }
-    
-    h2_worker_release_task(worker, task);
-    h2_mplx_task_done(task->mplx, task->stream_id);
-    
-    return status;
+    return APR_SUCCESS;
 }
 
 static apr_status_t h2_task_process_request(const h2_request *req, conn_rec *c)
@@ -261,7 +224,7 @@ static int h2_task_process_conn(conn_rec
     
     ctx = h2_ctx_get(c, 0);
     if (h2_ctx_is_task(ctx)) {
-        if (!ctx->task->serialize_headers) {
+        if (!ctx->task->ser_headers) {
             ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, c, 
                           "h2_h2, processing request directly");
             h2_task_process_request(ctx->task->request, c);

Modified: httpd/httpd/trunk/modules/http2/h2_task.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_task.h?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_task.h (original)
+++ httpd/httpd/trunk/modules/http2/h2_task.h Wed Dec 23 13:04:40 2015
@@ -48,30 +48,23 @@ typedef struct h2_task h2_task;
 struct h2_task {
     const char *id;
     int stream_id;
-    apr_pool_t *pool;
-    apr_bucket_alloc_t *bucket_alloc;
-
     struct h2_mplx *mplx;    
-    struct conn_rec *c;
     const struct h2_request *request;
     
-    unsigned int filters_set       : 1;
-    unsigned int input_eos         : 1;
-    unsigned int serialize_headers : 1;
+    unsigned int filters_set : 1;
+    unsigned int input_eos   : 1;
+    unsigned int ser_headers : 1;
     
     struct h2_task_input *input;
     struct h2_task_output *output;
-    
     struct apr_thread_cond_t *io;   /* used to wait for events on */
 };
 
 h2_task *h2_task_create(long session_id, const struct h2_request *req, 
-                        apr_pool_t *pool, struct h2_mplx *mplx, 
-                        int eos);
-
-apr_status_t h2_task_destroy(h2_task *task);
+                        apr_pool_t *pool, struct h2_mplx *mplx);
 
-apr_status_t h2_task_do(h2_task *task, struct h2_worker *worker);
+apr_status_t h2_task_do(h2_task *task, conn_rec *c, 
+                        struct apr_thread_cond_t *cond, apr_socket_t *socket);
 
 void h2_task_register_hooks(void);
 

Modified: httpd/httpd/trunk/modules/http2/h2_task_input.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_task_input.c?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_task_input.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_task_input.c Wed Dec 23 13:04:40 2015
@@ -51,8 +51,8 @@ h2_task_input *h2_task_input_create(h2_t
         input->task = task;
         input->bb = NULL;
         
-        if (task->serialize_headers) {
-            ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, task->c,
+        if (task->ser_headers) {
+            ap_log_perror(APLOG_MARK, APLOG_TRACE1, 0, pool,
                           "h2_task_input(%s): serialize request %s %s", 
                           task->id, task->request->method, task->request->path);
             input->bb = apr_brigade_create(pool, bucket_alloc);

Modified: httpd/httpd/trunk/modules/http2/h2_version.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_version.h?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_version.h (original)
+++ httpd/httpd/trunk/modules/http2/h2_version.h Wed Dec 23 13:04:40 2015
@@ -20,7 +20,7 @@
  * @macro
  * Version number of the h2 module as c string
  */
-#define MOD_HTTP2_VERSION "1.0.13-DEVa"
+#define MOD_HTTP2_VERSION "1.0.14-DEVa"
 
 /**
  * @macro
@@ -28,7 +28,7 @@
  * release. This is a 24 bit number with 8 bits for major number, 8 bits
  * for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203.
  */
-#define MOD_HTTP2_VERSION_NUM 0x01000d
+#define MOD_HTTP2_VERSION_NUM 0x01000e
 
 
 #endif /* mod_h2_h2_version_h */

Modified: httpd/httpd/trunk/modules/http2/h2_worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_worker.c?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_worker.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_worker.c Wed Dec 23 13:04:40 2015
@@ -24,6 +24,8 @@
 
 #include "h2_private.h"
 #include "h2_conn.h"
+#include "h2_ctx.h"
+#include "h2_h2.h"
 #include "h2_mplx.h"
 #include "h2_request.h"
 #include "h2_task.h"
@@ -34,6 +36,11 @@ static void* APR_THREAD_FUNC execute(apr
     h2_worker *worker = (h2_worker *)wctx;
     apr_status_t status = APR_SUCCESS;
     h2_mplx *m;
+    const h2_request *req;
+    h2_task *task;
+    conn_rec *c, *master;
+    int stream_id;
+    
     (void)thread;
     
     /* Furthermore, other code might want to see the socket for
@@ -50,15 +57,32 @@ static void* APR_THREAD_FUNC execute(apr
         return NULL;
     }
     
-    worker->task = NULL;
     m = NULL;
     while (!worker->aborted) {
-        status = worker->get_next(worker, &m, &worker->task, worker->ctx);
+        status = worker->get_next(worker, &m, &req, worker->ctx);
         
-        if (worker->task) {            
-            h2_task_do(worker->task, worker);
-            worker->task = NULL;
-            apr_thread_cond_signal(worker->io);
+        if (req) {
+            stream_id = req->id;
+            master = m->c;
+            c = h2_slave_create(master, worker->task_pool, 
+                                worker->thread, worker->socket);
+            if (!c) {
+                ap_log_cerror(APLOG_MARK, APLOG_WARNING, status, c,
+                              APLOGNO(02957) "h2_task(%s): error setting up slave connection", 
+                              task->id);
+                h2_mplx_out_rst(m, task->stream_id, H2_ERR_INTERNAL_ERROR);
+            }
+            else {
+                task = h2_task_create(m->id, req, worker->task_pool, m);
+                h2_ctx_create_for(c, task);
+                h2_task_do(task, c, worker->io, worker->socket);
+                
+                apr_thread_cond_signal(worker->io);
+            }
+            apr_pool_clear(worker->task_pool);
+            /* task is gone */
+            task = NULL;
+            h2_mplx_task_done(m, stream_id);
         }
     }
 
@@ -124,6 +148,7 @@ h2_worker *h2_worker_create(int id,
         }
         
         apr_pool_pre_cleanup_register(w->pool, w, cleanup_join_thread);
+        apr_pool_create(&w->task_pool, w->pool);
         apr_thread_create(&w->thread, attr, execute, w, w->pool);
     }
     return w;
@@ -158,52 +183,12 @@ int h2_worker_is_aborted(h2_worker *work
 }
 
 h2_task *h2_worker_create_task(h2_worker *worker, h2_mplx *m, 
-                               const h2_request *req, int eos)
+                               const h2_request *req)
 {
     h2_task *task;
     
-    /* Create a subpool from the worker one to be used for all things
-     * with life-time of this task execution.
-     */
-    if (!worker->task_pool) {
-        apr_pool_create(&worker->task_pool, worker->pool);
-        worker->pool_reuses = 100;
-    }
-    task = h2_task_create(m->id, req, worker->task_pool, m, eos);
-    
-    /* Link the task to the worker which provides useful things such
-     * as mutex, a socket etc. */
-    task->io = worker->io;
-    
+    task = h2_task_create(m->id, req, worker->task_pool, m);
     return task;
 }
 
-apr_status_t h2_worker_setup_task(h2_worker *worker, h2_task *task) {
-    apr_status_t status;
-    
-    
-    status = h2_slave_setup(task, apr_bucket_alloc_create(task->pool),
-                            worker->thread, worker->socket);
-    
-    return status;
-}
-
-void h2_worker_release_task(h2_worker *worker, struct h2_task *task)
-{
-    task->io = NULL;
-    task->pool = NULL;
-    if (worker->pool_reuses-- <= 0) {
-        apr_pool_destroy(worker->task_pool);
-        worker->task_pool = NULL;
-    }
-    else {
-        apr_pool_clear(worker->task_pool);
-    }
-}
-
-apr_socket_t *h2_worker_get_socket(h2_worker *worker)
-{
-    return worker->socket;
-}
-
 

Modified: httpd/httpd/trunk/modules/http2/h2_worker.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_worker.h?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_worker.h (original)
+++ httpd/httpd/trunk/modules/http2/h2_worker.h Wed Dec 23 13:04:40 2015
@@ -31,7 +31,7 @@ typedef struct h2_worker h2_worker;
  * gets aborted (idle timeout, for example). */
 typedef apr_status_t h2_worker_mplx_next_fn(h2_worker *worker,
                                             struct h2_mplx **pm,
-                                            struct h2_task **ptask,
+                                            const struct h2_request **preq,
                                             void *ctx);
 
 /* Invoked just before the worker thread exits. */
@@ -54,8 +54,6 @@ struct h2_worker {
     void *ctx;
     
     unsigned int aborted : 1;
-    int pool_reuses;
-    struct h2_task *task;
 };
 
 /**
@@ -145,10 +143,6 @@ int h2_worker_get_id(h2_worker *worker);
 int h2_worker_is_aborted(h2_worker *worker);
 
 struct h2_task *h2_worker_create_task(h2_worker *worker, struct h2_mplx *m, 
-                                      const struct h2_request *req, int eos);
-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);
-
+                                      const struct h2_request *req);
+                                      
 #endif /* defined(__mod_h2__h2_worker__) */

Modified: httpd/httpd/trunk/modules/http2/h2_workers.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_workers.c?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_workers.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_workers.c Wed Dec 23 13:04:40 2015
@@ -25,7 +25,7 @@
 
 #include "h2_private.h"
 #include "h2_mplx.h"
-#include "h2_task.h"
+#include "h2_request.h"
 #include "h2_task_queue.h"
 #include "h2_worker.h"
 #include "h2_workers.h"
@@ -68,20 +68,20 @@ static void cleanup_zombies(h2_workers *
  * the h2_workers lock.
  */
 static apr_status_t get_mplx_next(h2_worker *worker, h2_mplx **pm, 
-                                  h2_task **ptask, void *ctx)
+                                  const h2_request **preq, void *ctx)
 {
     apr_status_t status;
     h2_mplx *m = NULL;
-    h2_task *task = NULL;
+    const h2_request *req = NULL;
     apr_time_t max_wait, start_wait;
     int has_more = 0;
     h2_workers *workers = (h2_workers *)ctx;
     
-    if (*pm && ptask != NULL) {
+    if (*pm && preq != NULL) {
         /* We have a h2_mplx instance and the worker wants the next task. 
          * Try to get one from the given mplx. */
-        *ptask = h2_mplx_pop_task(*pm, worker, &has_more);
-        if (*ptask) {
+        *preq = h2_mplx_pop_request(*pm, &has_more);
+        if (*preq) {
             return APR_SUCCESS;
         }
     }
@@ -94,7 +94,7 @@ static apr_status_t get_mplx_next(h2_wor
         *pm = NULL;
     }
     
-    if (!ptask) {
+    if (!preq) {
         /* the worker does not want a next task, we're done.
          */
         return APR_SUCCESS;
@@ -109,7 +109,7 @@ static apr_status_t get_mplx_next(h2_wor
         ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, workers->s,
                      "h2_worker(%d): looking for work", h2_worker_get_id(worker));
         
-        while (!task && !h2_worker_is_aborted(worker) && !workers->aborted) {
+        while (!req && !h2_worker_is_aborted(worker) && !workers->aborted) {
             
             /* Get the next h2_mplx to process that has a task to hand out.
              * If it does, place it at the end of the queu and return the
@@ -121,12 +121,12 @@ static apr_status_t get_mplx_next(h2_wor
              * we do a timed wait or block indefinitely.
              */
             m = NULL;
-            while (!task && !H2_MPLX_LIST_EMPTY(&workers->mplxs)) {
+            while (!req && !H2_MPLX_LIST_EMPTY(&workers->mplxs)) {
                 m = H2_MPLX_LIST_FIRST(&workers->mplxs);
                 H2_MPLX_REMOVE(m);
                 
-                task = h2_mplx_pop_task(m, worker, &has_more);
-                if (task) {
+                req = h2_mplx_pop_request(m, &has_more);
+                if (req) {
                     if (has_more) {
                         H2_MPLX_LIST_INSERT_TAIL(&workers->mplxs, m);
                     }
@@ -137,7 +137,7 @@ static apr_status_t get_mplx_next(h2_wor
                 }
             }
             
-            if (!task) {
+            if (!req) {
                 /* Need to wait for either a new mplx to arrive.
                  */
                 cleanup_zombies(workers, 0);
@@ -174,16 +174,16 @@ static apr_status_t get_mplx_next(h2_wor
         /* Here, we either have gotten task and mplx for the worker or
          * needed to give up with more than enough workers.
          */
-        if (task) {
+        if (req) {
             ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, workers->s,
-                         "h2_worker(%d): start task(%s)",
-                         h2_worker_get_id(worker), task->id);
+                         "h2_worker(%d): start request(%ld-%d)",
+                         h2_worker_get_id(worker), m->id, req->id);
             /* Since we hand out a reference to the worker, we increase
              * its ref count.
              */
             h2_mplx_reference(m);
             *pm = m;
-            *ptask = task;
+            *preq = req;
             
             if (has_more && workers->idle_worker_count > 1) {
                 apr_thread_cond_signal(workers->mplx_added);

Modified: httpd/httpd/trunk/modules/http2/h2_workers.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_workers.h?rev=1721540&r1=1721539&r2=1721540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_workers.h (original)
+++ httpd/httpd/trunk/modules/http2/h2_workers.h Wed Dec 23 13:04:40 2015
@@ -25,6 +25,7 @@
 struct apr_thread_mutex_t;
 struct apr_thread_cond_t;
 struct h2_mplx;
+struct h2_request;
 struct h2_task;
 struct h2_task_queue;