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/11/23 20:18:49 UTC
svn commit: r1715925 - /httpd/httpd/branches/2.4-http2-alpha/modules/http2/
Author: icing
Date: Mon Nov 23 19:18:49 2015
New Revision: 1715925
URL: http://svn.apache.org/viewvc?rev=1715925&view=rev
Log:
update to 1.0.6-DEV of mod_http2
Modified:
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_bucket_eoc.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_config.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn_io.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn_io.h
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_from_h1.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_from_h1.h
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_h2.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io.h
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io_set.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io_set.h
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_mplx.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_mplx.h
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_push.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_request.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_response.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_response.h
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_session.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_session.h
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_stream.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_stream.h
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task_output.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task_output.h
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_util.c
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_util.h
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_version.h
httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_worker.c
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_bucket_eoc.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_bucket_eoc.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_bucket_eoc.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_bucket_eoc.c Mon Nov 23 19:18:49 2015
@@ -90,10 +90,11 @@ static void bucket_destroy(void *data)
if (apr_bucket_shared_destroy(h)) {
h2_session *session = h->session;
+ apr_bucket_free(h);
if (session) {
h2_session_eoc_callback(session);
+ /* all is gone now */
}
- apr_bucket_free(h);
}
}
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_config.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_config.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_config.c Mon Nov 23 19:18:49 2015
@@ -43,7 +43,7 @@ static h2_config defconf = {
H2_INITIAL_WINDOW_SIZE, /* window_size */
-1, /* min workers */
-1, /* max workers */
- 10 * 60, /* max workers idle secs */
+ 10, /* max workers idle secs */
64 * 1024, /* stream max mem size */
NULL, /* no alt-svcs */
-1, /* alt-svc max age */
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn.c Mon Nov 23 19:18:49 2015
@@ -177,10 +177,6 @@ apr_status_t h2_conn_process(conn_rec *c
ap_log_cerror( APLOG_MARK, APLOG_DEBUG, status, session->c,
"h2_session(%ld): done", session->id);
- h2_session_close(session);
- h2_session_flush(session);
- /* hereafter session might be gone */
-
/* Make sure this connection gets closed properly. */
ap_update_child_status_from_conn(c->sbh, SERVER_CLOSING, c);
c->keepalive = AP_CONN_CLOSE;
@@ -188,6 +184,8 @@ apr_status_t h2_conn_process(conn_rec *c
c->cs->state = CONN_STATE_WRITE_COMPLETION;
}
+ h2_session_close(session);
+ /* hereafter session will be gone */
return status;
}
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn_io.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn_io.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn_io.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn_io.c Mon Nov 23 19:18:49 2015
@@ -23,6 +23,7 @@
#include <http_connection.h>
#include "h2_private.h"
+#include "h2_bucket_eoc.h"
#include "h2_config.h"
#include "h2_conn_io.h"
#include "h2_h2.h"
@@ -44,20 +45,20 @@
#define WRITE_BUFFER_SIZE (8*WRITE_SIZE_MAX)
-apr_status_t h2_conn_io_init(h2_conn_io *io, conn_rec *c)
+apr_status_t h2_conn_io_init(h2_conn_io *io, conn_rec *c, apr_pool_t *pool)
{
h2_config *cfg = h2_config_get(c);
io->connection = c;
- io->input = apr_brigade_create(c->pool, c->bucket_alloc);
- io->output = apr_brigade_create(c->pool, c->bucket_alloc);
+ io->input = apr_brigade_create(pool, c->bucket_alloc);
+ io->output = apr_brigade_create(pool, c->bucket_alloc);
io->buflen = 0;
io->is_tls = h2_h2_is_tls(c);
io->buffer_output = io->is_tls;
if (io->buffer_output) {
io->bufsize = WRITE_BUFFER_SIZE;
- io->buffer = apr_pcalloc(c->pool, io->bufsize);
+ io->buffer = apr_pcalloc(pool, io->bufsize);
}
else {
io->bufsize = 0;
@@ -115,6 +116,8 @@ static apr_status_t h2_conn_io_bucket_re
&bucket_length, block);
if (status == APR_SUCCESS && bucket_length > 0) {
+ apr_size_t consumed = 0;
+
if (APLOGctrace2(io->connection)) {
char buffer[32];
h2_util_hex_dump(buffer, sizeof(buffer)/sizeof(buffer[0]),
@@ -124,20 +127,18 @@ static apr_status_t h2_conn_io_bucket_re
io->connection->id, (int)bucket_length, buffer);
}
- if (bucket_length > 0) {
- apr_size_t consumed = 0;
- status = on_read_cb(bucket_data, bucket_length,
- &consumed, pdone, puser);
- if (status == APR_SUCCESS && bucket_length > consumed) {
- /* We have data left in the bucket. Split it. */
- status = apr_bucket_split(bucket, consumed);
- }
- readlen += consumed;
+ status = on_read_cb(bucket_data, bucket_length, &consumed,
+ pdone, puser);
+ if (status == APR_SUCCESS && bucket_length > consumed) {
+ /* We have data left in the bucket. Split it. */
+ status = apr_bucket_split(bucket, consumed);
}
+ readlen += consumed;
}
}
apr_bucket_delete(bucket);
}
+
if (readlen == 0 && status == APR_SUCCESS && block == APR_NONBLOCK_READ) {
return APR_EAGAIN;
}
@@ -158,10 +159,10 @@ apr_status_t h2_conn_io_read(h2_conn_io
/* Seems something is left from a previous read, lets
* satisfy our caller with the data we already have. */
status = h2_conn_io_bucket_read(io, block, on_read_cb, puser, &done);
+ apr_brigade_cleanup(io->input);
if (status != APR_SUCCESS || done) {
return status;
}
- apr_brigade_cleanup(io->input);
}
/* We only do a blocking read when we have no streams to process. So,
@@ -179,6 +180,9 @@ apr_status_t h2_conn_io_read(h2_conn_io
ap_update_child_status(io->connection->sbh, SERVER_BUSY_READ, NULL);
}
+ /* TODO: replace this with a connection filter itself, so that we
+ * no longer need to transfer incoming buckets to our own brigade.
+ */
status = ap_get_brigade(io->connection->input_filters,
io->input, AP_MODE_READBYTES,
block, 64 * 4096);
@@ -379,4 +383,19 @@ apr_status_t h2_conn_io_flush(h2_conn_io
apr_status_t h2_conn_io_pass(h2_conn_io *io)
{
return h2_conn_io_flush_int(io, 0);
+}
+
+apr_status_t h2_conn_io_close(h2_conn_io *io, void *session)
+{
+ apr_bucket *b;
+
+ /* Send out anything in our buffers */
+ h2_conn_io_flush_int(io, 0);
+
+ b = h2_bucket_eoc_create(io->connection->bucket_alloc, session);
+ APR_BRIGADE_INSERT_TAIL(io->output, b);
+ b = apr_bucket_flush_create(io->connection->bucket_alloc);
+ APR_BRIGADE_INSERT_TAIL(io->output, b);
+ return ap_pass_brigade(io->connection->output_filters, io->output);
+ /* and all is gone */
}
\ No newline at end of file
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn_io.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn_io.h?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn_io.h (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_conn_io.h Mon Nov 23 19:18:49 2015
@@ -42,7 +42,7 @@ typedef struct {
int unflushed;
} h2_conn_io;
-apr_status_t h2_conn_io_init(h2_conn_io *io, conn_rec *c);
+apr_status_t h2_conn_io_init(h2_conn_io *io, conn_rec *c, apr_pool_t *pool);
int h2_conn_io_is_buffered(h2_conn_io *io);
@@ -65,5 +65,6 @@ apr_status_t h2_conn_io_consider_flush(h
apr_status_t h2_conn_io_pass(h2_conn_io *io);
apr_status_t h2_conn_io_flush(h2_conn_io *io);
+apr_status_t h2_conn_io_close(h2_conn_io *io, void *session);
#endif /* defined(__mod_h2__h2_conn_io__) */
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_from_h1.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_from_h1.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_from_h1.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_from_h1.c Mon Nov 23 19:18:49 2015
@@ -262,7 +262,7 @@ static int uniq_field_values(void *d, co
*/
for (i = 0, strpp = (char **) values->elts; i < values->nelts;
++i, ++strpp) {
- if (*strpp && strcasecmp(*strpp, start) == 0) {
+ if (*strpp && ap_casecmpstr(*strpp, start) == 0) {
break;
}
}
@@ -411,7 +411,7 @@ static h2_response *create_response(h2_f
while (field && (token = ap_get_list_item(r->pool, &field)) != NULL) {
for (i = 0; i < r->content_languages->nelts; ++i) {
- if (!strcasecmp(token, languages[i]))
+ if (!ap_casecmpstr(token, languages[i]))
break;
}
if (i == r->content_languages->nelts) {
@@ -555,3 +555,38 @@ apr_status_t h2_response_output_filter(a
}
return ap_pass_brigade(f->next, bb);
}
+
+apr_status_t h2_response_trailers_filter(ap_filter_t *f, apr_bucket_brigade *bb)
+{
+ h2_task *task = f->ctx;
+ h2_from_h1 *from_h1 = task->output? task->output->from_h1 : NULL;
+ request_rec *r = f->r;
+ apr_bucket *b;
+
+ if (from_h1 && from_h1->response) {
+ /* Detect the EOR bucket and forward any trailers that may have
+ * been set to our h2_response.
+ */
+ for (b = APR_BRIGADE_FIRST(bb);
+ b != APR_BRIGADE_SENTINEL(bb);
+ b = APR_BUCKET_NEXT(b))
+ {
+ if (AP_BUCKET_IS_EOR(b)) {
+ /* FIXME: need a better test case than this.
+ apr_table_setn(r->trailers_out, "X", "1"); */
+ if (r->trailers_out && !apr_is_empty_table(r->trailers_out)) {
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, f->c,
+ "h2_from_h1(%d): trailers filter, saving trailers",
+ from_h1->stream_id);
+ h2_response_set_trailers(from_h1->response,
+ apr_table_clone(from_h1->pool,
+ r->trailers_out));
+ }
+ break;
+ }
+ }
+ }
+
+ return ap_pass_brigade(f->next, bb);
+}
+
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_from_h1.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_from_h1.h?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_from_h1.h (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_from_h1.h Mon Nov 23 19:18:49 2015
@@ -69,4 +69,6 @@ struct h2_response *h2_from_h1_get_respo
apr_status_t h2_response_output_filter(ap_filter_t *f, apr_bucket_brigade *bb);
+apr_status_t h2_response_trailers_filter(ap_filter_t *f, apr_bucket_brigade *bb);
+
#endif /* defined(__mod_h2__h2_from_h1__) */
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_h2.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_h2.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_h2.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_h2.c Mon Nov 23 19:18:49 2015
@@ -667,16 +667,17 @@ static int h2_h2_post_read_req(request_r
ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r,
"adding h1_to_h2_resp output filter");
if (task->serialize_headers) {
- ap_remove_output_filter_byhandle(r->output_filters, "H1_TO_H2_RESP");
+/* ap_remove_output_filter_byhandle(r->output_filters, "H1_TO_H2_RESP");*/
ap_add_output_filter("H1_TO_H2_RESP", task, r, r->connection);
}
else {
/* replace the core http filter that formats response headers
* in HTTP/1 with our own that collects status and headers */
ap_remove_output_filter_byhandle(r->output_filters, "HTTP_HEADER");
- ap_remove_output_filter_byhandle(r->output_filters, "H2_RESPONSE");
+/* ap_remove_output_filter_byhandle(r->output_filters, "H2_RESPONSE");*/
ap_add_output_filter("H2_RESPONSE", task, r, r->connection);
}
+ ap_add_output_filter("H2_TRAILERS", task, r, r->connection);
}
return DECLINED;
}
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io.c Mon Nov 23 19:18:49 2015
@@ -205,8 +205,17 @@ apr_status_t h2_io_out_read_to(h2_io *io
return h2_util_move(bb, io->bbout, *plen, NULL, "h2_io_read_to");
}
+static void process_trailers(h2_io *io, apr_table_t *trailers)
+{
+ if (trailers && io->response) {
+ h2_response_set_trailers(io->response,
+ apr_table_clone(io->pool, trailers));
+ }
+}
+
apr_status_t h2_io_out_write(h2_io *io, apr_bucket_brigade *bb,
- apr_size_t maxlen, int *pfile_handles_allowed)
+ apr_size_t maxlen, apr_table_t *trailers,
+ int *pfile_handles_allowed)
{
apr_status_t status;
int start_allowed;
@@ -233,6 +242,7 @@ apr_status_t h2_io_out_write(h2_io *io,
return status;
}
+ process_trailers(io, trailers);
if (!io->bbout) {
io->bbout = apr_brigade_create(io->pool, io->bucket_alloc);
}
@@ -258,17 +268,20 @@ apr_status_t h2_io_out_write(h2_io *io,
}
-apr_status_t h2_io_out_close(h2_io *io)
+apr_status_t h2_io_out_close(h2_io *io, apr_table_t *trailers)
{
if (io->rst_error) {
return APR_ECONNABORTED;
}
- if (!io->bbout) {
- io->bbout = apr_brigade_create(io->pool, io->bucket_alloc);
- }
- if (!io->eos_out && !h2_util_has_eos(io->bbout, -1)) {
- APR_BRIGADE_INSERT_TAIL(io->bbout,
- apr_bucket_eos_create(io->bbout->bucket_alloc));
+ if (!io->eos_out) { /* EOS has not been read yet */
+ process_trailers(io, trailers);
+ if (!io->bbout) {
+ io->bbout = apr_brigade_create(io->pool, io->bucket_alloc);
+ }
+ if (!h2_util_has_eos(io->bbout, -1)) {
+ APR_BRIGADE_INSERT_TAIL(io->bbout,
+ apr_bucket_eos_create(io->bbout->bucket_alloc));
+ }
}
return APR_SUCCESS;
}
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io.h?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io.h (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io.h Mon Nov 23 19:18:49 2015
@@ -130,13 +130,14 @@ apr_status_t h2_io_out_read_to(h2_io *io
apr_off_t *plen, int *peos);
apr_status_t h2_io_out_write(h2_io *io, apr_bucket_brigade *bb,
- apr_size_t maxlen, int *pfile_buckets_allowed);
+ apr_size_t maxlen, apr_table_t *trailers,
+ int *pfile_buckets_allowed);
/**
* Closes the input. After existing data has been read, APR_EOF will
* be returned.
*/
-apr_status_t h2_io_out_close(h2_io *io);
+apr_status_t h2_io_out_close(h2_io *io, apr_table_t *trailers);
/**
* Gives the overall length of the data that is currently queued for
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io_set.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io_set.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io_set.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io_set.c Mon Nov 23 19:18:49 2015
@@ -145,37 +145,23 @@ h2_io *h2_io_set_pop_highest_prio(h2_io_
return NULL;
}
-void h2_io_set_destroy_all(h2_io_set *sp)
-{
- int i;
- for (i = 0; i < sp->list->nelts; ++i) {
- h2_io *io = h2_io_IDX(sp->list, i);
- h2_io_destroy(io);
- }
- sp->list->nelts = 0;
-}
-
-void h2_io_set_remove_all(h2_io_set *sp)
-{
- sp->list->nelts = 0;
-}
-
int h2_io_set_is_empty(h2_io_set *sp)
{
AP_DEBUG_ASSERT(sp);
return sp->list->nelts == 0;
}
-void h2_io_set_iter(h2_io_set *sp,
+int h2_io_set_iter(h2_io_set *sp,
h2_io_set_iter_fn *iter, void *ctx)
{
int i;
for (i = 0; i < sp->list->nelts; ++i) {
h2_io *s = h2_io_IDX(sp->list, i);
if (!iter(ctx, s)) {
- break;
+ return 0;
}
}
+ return 1;
}
apr_size_t h2_io_set_size(h2_io_set *sp)
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io_set.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io_set.h?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io_set.h (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_io_set.h Mon Nov 23 19:18:49 2015
@@ -32,16 +32,24 @@ apr_status_t h2_io_set_add(h2_io_set *se
h2_io *h2_io_set_get(h2_io_set *set, int stream_id);
h2_io *h2_io_set_remove(h2_io_set *set, struct h2_io *io);
-void h2_io_set_remove_all(h2_io_set *set);
-void h2_io_set_destroy_all(h2_io_set *set);
int h2_io_set_is_empty(h2_io_set *set);
apr_size_t h2_io_set_size(h2_io_set *set);
typedef int h2_io_set_iter_fn(void *ctx, struct h2_io *io);
-void h2_io_set_iter(h2_io_set *set,
- h2_io_set_iter_fn *iter, void *ctx);
+/**
+ * Iterator over all h2_io* in the set or until a
+ * callback returns 0. It is not safe to add or remove
+ * set members during iteration.
+ *
+ * @param set the set of h2_io to iterate over
+ * @param iter the function to call for each io
+ * @param ctx user data for the callback
+ * @return 1 iff iteration completed for all members
+ */
+int h2_io_set_iter(h2_io_set *set,
+ h2_io_set_iter_fn *iter, void *ctx);
h2_io *h2_io_set_pop_highest_prio(h2_io_set *set);
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_mplx.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_mplx.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_mplx.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_mplx.c Mon Nov 23 19:18:49 2015
@@ -73,6 +73,9 @@ static void have_out_data_for(h2_mplx *m
static void h2_mplx_destroy(h2_mplx *m)
{
AP_DEBUG_ASSERT(m);
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, m->c,
+ "h2_mplx(%ld): destroy, refs=%d",
+ m->id, m->refs);
m->aborted = 1;
if (m->ready_ios) {
h2_io_set_destroy(m->ready_ios);
@@ -83,15 +86,6 @@ static void h2_mplx_destroy(h2_mplx *m)
m->stream_ios = NULL;
}
- if (m->lock) {
- apr_thread_mutex_destroy(m->lock);
- 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);
}
@@ -199,13 +193,62 @@ static void workers_unregister(h2_mplx *
h2_workers_unregister(m->workers, m);
}
+static void io_destroy(h2_mplx *m, h2_io *io)
+{
+ apr_pool_t *pool = io->pool;
+
+ io->pool = NULL;
+ /* The pool is cleared/destroyed which also closes all
+ * allocated file handles. Give this count back to our
+ * file handle pool. */
+ m->file_handles_allowed += io->files_handles_owned;
+ h2_io_set_remove(m->stream_ios, io);
+ h2_io_set_remove(m->ready_ios, io);
+ h2_io_destroy(io);
+
+ if (pool) {
+ apr_pool_clear(pool);
+ if (m->spare_pool) {
+ apr_pool_destroy(m->spare_pool);
+ }
+ m->spare_pool = pool;
+ }
+}
+
+static int io_stream_done(h2_mplx *m, h2_io *io, int rst_error)
+{
+ /* Remove io from ready set, we will never submit it */
+ h2_io_set_remove(m->ready_ios, io);
+ if (io->task_done || h2_tq_remove(m->q, io->id)) {
+ /* already finished or not even started yet */
+ io_destroy(m, io);
+ return 0;
+ }
+ else {
+ /* cleanup once task is done */
+ io->orphaned = 1;
+ if (rst_error) {
+ h2_io_rst(io, rst_error);
+ }
+ return 1;
+ }
+}
+
+static int stream_done_iter(void *ctx, h2_io *io) {
+ return io_stream_done((h2_mplx*)ctx, io, 0);
+}
+
apr_status_t h2_mplx_release_and_join(h2_mplx *m, apr_thread_cond_t *wait)
{
apr_status_t status;
+
workers_unregister(m);
-
status = apr_thread_mutex_lock(m->lock);
if (APR_SUCCESS == status) {
+ while (!h2_io_set_iter(m->stream_ios, stream_done_iter, m)) {
+ /* iterator until all h2_io have been orphaned or destroyed */
+ }
+
release(m, 0);
while (m->refs > 0) {
m->join_wait = wait;
@@ -215,10 +258,11 @@ apr_status_t h2_mplx_release_and_join(h2
apr_thread_cond_wait(wait, m->lock);
}
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, m->c,
- "h2_mplx(%ld): release_join -> destroy", m->id);
- m->pool = NULL;
- apr_thread_mutex_unlock(m->lock);
+ "h2_mplx(%ld): release_join -> destroy, (#ios=%ld)",
+ m->id, (long)h2_io_set_size(m->stream_ios));
h2_mplx_destroy(m);
+ /* all gone */
+ /*apr_thread_mutex_unlock(m->lock);*/
}
return status;
}
@@ -230,33 +274,8 @@ void h2_mplx_abort(h2_mplx *m)
status = apr_thread_mutex_lock(m->lock);
if (APR_SUCCESS == status) {
m->aborted = 1;
- h2_io_set_destroy_all(m->stream_ios);
apr_thread_mutex_unlock(m->lock);
}
- workers_unregister(m);
-}
-
-
-static void io_destroy(h2_mplx *m, h2_io *io)
-{
- apr_pool_t *pool = io->pool;
-
- io->pool = NULL;
- /* The pool is cleared/destroyed which also closes all
- * allocated file handles. Give this count back to our
- * file handle pool. */
- m->file_handles_allowed += io->files_handles_owned;
- h2_io_set_remove(m->stream_ios, io);
- h2_io_set_remove(m->ready_ios, io);
- h2_io_destroy(io);
-
- if (pool) {
- apr_pool_clear(pool);
- if (m->spare_pool) {
- apr_pool_destroy(m->spare_pool);
- }
- m->spare_pool = pool;
- }
}
apr_status_t h2_mplx_stream_done(h2_mplx *m, int stream_id, int rst_error)
@@ -264,9 +283,6 @@ apr_status_t h2_mplx_stream_done(h2_mplx
apr_status_t status;
AP_DEBUG_ASSERT(m);
- if (m->aborted) {
- return APR_ECONNABORTED;
- }
status = apr_thread_mutex_lock(m->lock);
if (APR_SUCCESS == status) {
h2_io *io = h2_io_set_get(m->stream_ios, stream_id);
@@ -275,20 +291,7 @@ apr_status_t h2_mplx_stream_done(h2_mplx
* for processing, e.g. when we received all HEADERs. But when
* a stream is cancelled very early, it will not exist. */
if (io) {
- /* Remove io from ready set, we will never submit it */
- h2_io_set_remove(m->ready_ios, io);
- if (io->task_done || h2_tq_remove(m->q, io->id)) {
- /* already finished or not even started yet */
- io_destroy(m, io);
- }
- else {
- /* cleanup once task is done */
- io->orphaned = 1;
- if (rst_error) {
- h2_io_rst(io, rst_error);
- }
- }
-
+ io_stream_done(m, io, rst_error);
}
apr_thread_mutex_unlock(m->lock);
@@ -447,7 +450,8 @@ apr_status_t h2_mplx_in_update_windows(h
apr_status_t h2_mplx_out_readx(h2_mplx *m, int stream_id,
h2_io_data_cb *cb, void *ctx,
- apr_off_t *plen, int *peos)
+ apr_off_t *plen, int *peos,
+ apr_table_t **ptrailers)
{
apr_status_t status;
AP_DEBUG_ASSERT(m);
@@ -461,7 +465,6 @@ apr_status_t h2_mplx_out_readx(h2_mplx *
H2_MPLX_IO_OUT(APLOG_TRACE2, m, io, "h2_mplx_out_readx_pre");
status = h2_io_out_readx(io, cb, ctx, plen, peos);
-
H2_MPLX_IO_OUT(APLOG_TRACE2, m, io, "h2_mplx_out_readx_post");
if (status == APR_SUCCESS && cb && io->output_drained) {
apr_thread_cond_signal(io->output_drained);
@@ -470,6 +473,8 @@ apr_status_t h2_mplx_out_readx(h2_mplx *
else {
status = APR_ECONNABORTED;
}
+
+ *ptrailers = (*peos && io->response)? io->response->trailers : NULL;
apr_thread_mutex_unlock(m->lock);
}
return status;
@@ -477,7 +482,8 @@ apr_status_t h2_mplx_out_readx(h2_mplx *
apr_status_t h2_mplx_out_read_to(h2_mplx *m, int stream_id,
apr_bucket_brigade *bb,
- apr_off_t *plen, int *peos)
+ apr_off_t *plen, int *peos,
+ apr_table_t **ptrailers)
{
apr_status_t status;
AP_DEBUG_ASSERT(m);
@@ -500,6 +506,7 @@ apr_status_t h2_mplx_out_read_to(h2_mplx
else {
status = APR_ECONNABORTED;
}
+ *ptrailers = (*peos && io->response)? io->response->trailers : NULL;
apr_thread_mutex_unlock(m->lock);
}
return status;
@@ -560,6 +567,7 @@ h2_stream *h2_mplx_next_submit(h2_mplx *
static apr_status_t out_write(h2_mplx *m, h2_io *io,
ap_filter_t* f, apr_bucket_brigade *bb,
+ apr_table_t *trailers,
struct apr_thread_cond_t *iowait)
{
apr_status_t status = APR_SUCCESS;
@@ -572,7 +580,7 @@ static apr_status_t out_write(h2_mplx *m
&& (status == APR_SUCCESS)
&& !is_aborted(m, &status)) {
- status = h2_io_out_write(io, bb, m->stream_max_mem,
+ status = h2_io_out_write(io, bb, m->stream_max_mem, trailers,
&m->file_handles_allowed);
/* Wait for data to drain until there is room again */
while (!APR_BRIGADE_EMPTY(bb)
@@ -580,6 +588,7 @@ static apr_status_t out_write(h2_mplx *m
&& status == APR_SUCCESS
&& (m->stream_max_mem <= h2_io_out_length(io))
&& !is_aborted(m, &status)) {
+ trailers = NULL;
io->output_drained = iowait;
if (f) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, f->c,
@@ -613,7 +622,7 @@ static apr_status_t out_open(h2_mplx *m,
h2_io_set_response(io, response);
h2_io_set_add(m->ready_ios, io);
if (bb) {
- status = out_write(m, io, f, bb, iowait);
+ status = out_write(m, io, f, bb, response->trailers, iowait);
}
have_out_data_for(m, stream_id);
}
@@ -649,6 +658,7 @@ apr_status_t h2_mplx_out_open(h2_mplx *m
apr_status_t h2_mplx_out_write(h2_mplx *m, int stream_id,
ap_filter_t* f, apr_bucket_brigade *bb,
+ apr_table_t *trailers,
struct apr_thread_cond_t *iowait)
{
apr_status_t status;
@@ -661,7 +671,10 @@ apr_status_t h2_mplx_out_write(h2_mplx *
if (!m->aborted) {
h2_io *io = h2_io_set_get(m->stream_ios, stream_id);
if (io && !io->orphaned) {
- status = out_write(m, io, f, bb, iowait);
+ status = out_write(m, io, f, bb, trailers, iowait);
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, m->c,
+ "h2_mplx(%ld-%d): write with trailers=%s",
+ m->id, io->id, trailers? "yes" : "no");
H2_MPLX_IO_OUT(APLOG_TRACE2, m, io, "h2_mplx_out_write");
have_out_data_for(m, stream_id);
@@ -681,7 +694,7 @@ apr_status_t h2_mplx_out_write(h2_mplx *
return status;
}
-apr_status_t h2_mplx_out_close(h2_mplx *m, int stream_id)
+apr_status_t h2_mplx_out_close(h2_mplx *m, int stream_id, apr_table_t *trailers)
{
apr_status_t status;
AP_DEBUG_ASSERT(m);
@@ -705,7 +718,10 @@ apr_status_t h2_mplx_out_close(h2_mplx *
"h2_mplx(%ld-%d): close, no response, no rst",
m->id, io->id);
}
- status = h2_io_out_close(io);
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, m->c,
+ "h2_mplx(%ld-%d): close with trailers=%s",
+ m->id, io->id, trailers? "yes" : "no");
+ status = h2_io_out_close(io, trailers);
H2_MPLX_IO_OUT(APLOG_TRACE2, m, io, "h2_mplx_out_close");
have_out_data_for(m, stream_id);
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_mplx.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_mplx.h?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_mplx.h (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_mplx.h Mon Nov 23 19:18:49 2015
@@ -240,7 +240,8 @@ struct h2_stream *h2_mplx_next_submit(h2
*/
apr_status_t h2_mplx_out_readx(h2_mplx *mplx, int stream_id,
h2_io_data_cb *cb, void *ctx,
- apr_off_t *plen, int *peos);
+ apr_off_t *plen, int *peos,
+ apr_table_t **ptrailers);
/**
* Reads output data into the given brigade. Will never block, but
@@ -248,7 +249,8 @@ apr_status_t h2_mplx_out_readx(h2_mplx *
*/
apr_status_t h2_mplx_out_read_to(h2_mplx *mplx, int stream_id,
apr_bucket_brigade *bb,
- apr_off_t *plen, int *peos);
+ apr_off_t *plen, int *peos,
+ apr_table_t **ptrailers);
/**
* Opens the output for the given stream with the specified response.
@@ -264,17 +266,19 @@ apr_status_t h2_mplx_out_open(h2_mplx *m
* @param stream_id the stream identifier
* @param filter the apache filter context of the data
* @param bb the bucket brigade to append
+ * @param trailers optional trailers for response, maybe NULL
* @param iowait a conditional used for block/signalling in h2_mplx
*/
apr_status_t h2_mplx_out_write(h2_mplx *mplx, int stream_id,
ap_filter_t* filter, apr_bucket_brigade *bb,
+ apr_table_t *trailers,
struct apr_thread_cond_t *iowait);
/**
- * Closes the output stream. Readers of this stream will get all pending
- * data and then only APR_EOF as result.
+ * Closes the output for stream stream_id. Optionally forwards trailers
+ * fromt the processed stream.
*/
-apr_status_t h2_mplx_out_close(h2_mplx *m, int stream_id);
+apr_status_t h2_mplx_out_close(h2_mplx *m, int stream_id, apr_table_t *trailers);
apr_status_t h2_mplx_out_rst(h2_mplx *m, int stream_id, int error);
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_push.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_push.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_push.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_push.c Mon Nov 23 19:18:49 2015
@@ -386,14 +386,14 @@ apr_array_header_t *h2_push_collect(apr_
* TODO: This may be extended in the future by hooks or callbacks
* where other modules can provide push information directly.
*/
- if (res->header) {
+ if (res->headers) {
link_ctx ctx;
memset(&ctx, 0, sizeof(ctx));
ctx.req = req;
ctx.pool = p;
- apr_table_do(head_iter, &ctx, res->header, NULL);
+ apr_table_do(head_iter, &ctx, res->headers, NULL);
return ctx.pushes;
}
return NULL;
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_request.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_request.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_request.c Mon Nov 23 19:18:49 2015
@@ -69,14 +69,7 @@ static apr_status_t add_h1_header(h2_req
{
char *hname, *hvalue;
- if (H2_HD_MATCH_LIT("expect", name, nlen)
- || H2_HD_MATCH_LIT("upgrade", name, nlen)
- || H2_HD_MATCH_LIT("connection", name, nlen)
- || H2_HD_MATCH_LIT("proxy-connection", name, nlen)
- || H2_HD_MATCH_LIT("transfer-encoding", name, nlen)
- || H2_HD_MATCH_LIT("keep-alive", name, nlen)
- || H2_HD_MATCH_LIT("http2-settings", name, nlen)) {
- /* ignore these. */
+ if (h2_req_ignore_header(name, nlen)) {
return APR_SUCCESS;
}
else if (H2_HD_MATCH_LIT("cookie", name, nlen)) {
@@ -115,7 +108,10 @@ typedef struct {
static int set_h1_header(void *ctx, const char *key, const char *value)
{
h1_ctx *x = ctx;
- add_h1_header(x->req, x->pool, key, strlen(key), value, strlen(value));
+ size_t klen = strlen(key);
+ if (!h2_req_ignore_header(key, klen)) {
+ add_h1_header(x->req, x->pool, key, klen, value, strlen(value));
+ }
return 1;
}
@@ -222,23 +218,11 @@ apr_status_t h2_request_end_headers(h2_r
return APR_EINVAL;
}
- /* be safe, some header we do not accept on h2(c) */
- apr_table_unset(req->headers, "expect");
- apr_table_unset(req->headers, "upgrade");
- apr_table_unset(req->headers, "connection");
- apr_table_unset(req->headers, "proxy-connection");
- apr_table_unset(req->headers, "transfer-encoding");
- apr_table_unset(req->headers, "keep-alive");
- apr_table_unset(req->headers, "http2-settings");
-
- if (!apr_table_get(req->headers, "Host")) {
- /* Need to add a "Host" header if not already there to
- * make virtual hosts work correctly. */
- if (!req->authority) {
- return APR_BADARG;
- }
- apr_table_set(req->headers, "Host", req->authority);
+ /* Always set the "Host" header from :authority, see rfc7540, ch. 8.1.2.3 */
+ if (!req->authority) {
+ return APR_BADARG;
}
+ apr_table_setn(req->headers, "Host", req->authority);
s = apr_table_get(req->headers, "Content-Length");
if (s) {
@@ -290,15 +274,7 @@ static apr_status_t add_h1_trailer(h2_re
{
char *hname, *hvalue;
- if (H2_HD_MATCH_LIT("expect", name, nlen)
- || H2_HD_MATCH_LIT("upgrade", name, nlen)
- || H2_HD_MATCH_LIT("connection", name, nlen)
- || H2_HD_MATCH_LIT("host", name, nlen)
- || H2_HD_MATCH_LIT("proxy-connection", name, nlen)
- || H2_HD_MATCH_LIT("transfer-encoding", name, nlen)
- || H2_HD_MATCH_LIT("keep-alive", name, nlen)
- || H2_HD_MATCH_LIT("http2-settings", name, nlen)) {
- /* ignore these. */
+ if (h2_req_ignore_trailer(name, nlen)) {
return APR_SUCCESS;
}
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_response.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_response.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_response.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_response.c Mon Nov 23 19:18:49 2015
@@ -36,7 +36,7 @@ h2_response *h2_response_create(int stre
apr_array_header_t *hlines,
apr_pool_t *pool)
{
- apr_table_t *header;
+ apr_table_t *headers;
h2_response *response = apr_pcalloc(pool, sizeof(h2_response));
int i;
if (response == NULL) {
@@ -49,7 +49,7 @@ h2_response *h2_response_create(int stre
response->content_length = -1;
if (hlines) {
- header = apr_table_make(pool, hlines->nelts);
+ headers = apr_table_make(pool, hlines->nelts);
for (i = 0; i < hlines->nelts; ++i) {
char *hline = ((char **)hlines->elts)[i];
char *sep = ap_strchr(hline, ':');
@@ -66,7 +66,7 @@ h2_response *h2_response_create(int stre
}
if (!h2_util_ignore_header(hline)) {
- apr_table_merge(header, hline, sep);
+ apr_table_merge(headers, hline, sep);
if (*sep && H2_HD_MATCH_LIT_CS("content-length", hline)) {
char *end;
response->content_length = apr_strtoi64(sep, &end, 10);
@@ -83,10 +83,10 @@ h2_response *h2_response_create(int stre
}
}
else {
- header = apr_table_make(pool, 0);
+ headers = apr_table_make(pool, 0);
}
- response->header = header;
+ response->headers = headers;
return response;
}
@@ -101,7 +101,7 @@ h2_response *h2_response_rcreate(int str
response->stream_id = stream_id;
response->http_status = r->status;
response->content_length = -1;
- response->header = header;
+ response->headers = header;
if (response->http_status == HTTP_FORBIDDEN) {
const char *cause = apr_table_get(r->notes, "ssl-renegotiate-forbidden");
@@ -130,10 +130,17 @@ h2_response *h2_response_copy(apr_pool_t
to->stream_id = from->stream_id;
to->http_status = from->http_status;
to->content_length = from->content_length;
- if (from->header) {
- to->header = apr_table_clone(pool, from->header);
+ if (from->headers) {
+ to->headers = apr_table_clone(pool, from->headers);
+ }
+ if (from->trailers) {
+ to->trailers = apr_table_clone(pool, from->trailers);
}
return to;
}
+void h2_response_set_trailers(h2_response *response, apr_table_t *trailers)
+{
+ response->trailers = trailers;
+}
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_response.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_response.h?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_response.h (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_response.h Mon Nov 23 19:18:49 2015
@@ -23,7 +23,8 @@ typedef struct h2_response {
int rst_error;
int http_status;
apr_off_t content_length;
- apr_table_t *header;
+ apr_table_t *headers;
+ apr_table_t *trailers;
} h2_response;
h2_response *h2_response_create(int stream_id,
@@ -39,4 +40,13 @@ void h2_response_destroy(h2_response *re
h2_response *h2_response_copy(apr_pool_t *pool, h2_response *from);
+/**
+ * Set the trailers in the reponse. Will replace any existing trailers. Will
+ * *not* clone the table.
+ *
+ * @param response the repsone to set the trailers for
+ * @param trailers the trailers to set
+ */
+void h2_response_set_trailers(h2_response *response, apr_table_t *trailers);
+
#endif /* defined(__mod_h2__h2_response__) */
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_session.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_session.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_session.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_session.c Mon Nov 23 19:18:49 2015
@@ -24,7 +24,6 @@
#include <http_log.h>
#include "h2_private.h"
-#include "h2_bucket_eoc.h"
#include "h2_bucket_eos.h"
#include "h2_config.h"
#include "h2_h2.h"
@@ -84,11 +83,6 @@ h2_stream *h2_session_open_stream(h2_ses
return stream;
}
-apr_status_t h2_session_flush(h2_session *session)
-{
- return h2_conn_io_flush(&session->io);
-}
-
/**
* Determine the importance of streams when scheduling tasks.
* - if both stream depend on the same one, compare weights
@@ -590,6 +584,44 @@ static apr_status_t session_pool_cleanup
return APR_SUCCESS;
}
+static void *session_malloc(size_t size, void *ctx)
+{
+ h2_session *session = ctx;
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE6, 0, session->c,
+ "h2_session(%ld): malloc(%ld)",
+ session->id, (long)size);
+ return malloc(size);
+}
+
+static void session_free(void *p, void *ctx)
+{
+ h2_session *session = ctx;
+
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE6, 0, session->c,
+ "h2_session(%ld): free()",
+ session->id);
+ free(p);
+}
+
+static void *session_calloc(size_t n, size_t size, void *ctx)
+{
+ h2_session *session = ctx;
+
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE6, 0, session->c,
+ "h2_session(%ld): calloc(%ld, %ld)",
+ session->id, (long)n, (long)size);
+ return calloc(n, size);
+}
+
+static void *session_realloc(void *p, size_t size, void *ctx)
+{
+ h2_session *session = ctx;
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE6, 0, session->c,
+ "h2_session(%ld): realloc(%ld)",
+ session->id, (long)size);
+ return realloc(p, size);
+}
+
static h2_session *h2_session_create_int(conn_rec *c,
request_rec *r,
h2_config *config,
@@ -608,17 +640,18 @@ static h2_session *h2_session_create_int
session = apr_pcalloc(pool, sizeof(h2_session));
if (session) {
int rv;
+ nghttp2_mem *mem;
+
session->id = c->id;
session->c = c;
session->r = r;
+ session->pool = pool;
apr_pool_pre_cleanup_register(pool, session, session_pool_cleanup);
session->max_stream_count = h2_config_geti(config, H2_CONF_MAX_STREAMS);
session->max_stream_mem = h2_config_geti(config, H2_CONF_STREAM_MAX_MEM);
- session->pool = pool;
-
status = apr_thread_cond_create(&session->iowait, session->pool);
if (status != APR_SUCCESS) {
return NULL;
@@ -629,7 +662,7 @@ static h2_session *h2_session_create_int
session->workers = workers;
session->mplx = h2_mplx_create(c, session->pool, workers);
- h2_conn_io_init(&session->io, c);
+ h2_conn_io_init(&session->io, c, session->pool);
session->bbtmp = apr_brigade_create(session->pool, c->bucket_alloc);
status = init_callbacks(c, &callbacks);
@@ -648,16 +681,27 @@ static h2_session *h2_session_create_int
h2_session_destroy(session);
return NULL;
}
-
nghttp2_option_set_peer_max_concurrent_streams(options,
(uint32_t)session->max_stream_count);
-
/* We need to handle window updates ourself, otherwise we
* get flooded by nghttp2. */
nghttp2_option_set_no_auto_window_update(options, 1);
- rv = nghttp2_session_server_new2(&session->ngh2, callbacks,
- session, options);
+ if (APLOGctrace6(c)) {
+ mem = apr_pcalloc(session->pool, sizeof(nghttp2_mem));
+ mem->mem_user_data = session;
+ mem->malloc = session_malloc;
+ mem->free = session_free;
+ mem->calloc = session_calloc;
+ mem->realloc = session_realloc;
+
+ rv = nghttp2_session_server_new3(&session->ngh2, callbacks,
+ session, options, mem);
+ }
+ else {
+ rv = nghttp2_session_server_new2(&session->ngh2, callbacks,
+ session, options);
+ }
nghttp2_session_callbacks_del(callbacks);
nghttp2_option_del(options);
@@ -703,10 +747,6 @@ static void h2_session_cleanup(h2_sessio
apr_pool_destroy(session->spare);
session->spare = NULL;
}
- if (session->mplx) {
- h2_mplx_release_and_join(session->mplx, session->iowait);
- session->mplx = NULL;
- }
}
void h2_session_destroy(h2_session *session)
@@ -714,6 +754,10 @@ void h2_session_destroy(h2_session *sess
AP_DEBUG_ASSERT(session);
h2_session_cleanup(session);
+ if (session->mplx) {
+ h2_mplx_release_and_join(session->mplx, session->iowait);
+ session->mplx = NULL;
+ }
if (session->streams) {
if (!h2_stream_set_is_empty(session->streams)) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
@@ -993,10 +1037,8 @@ apr_status_t h2_session_close(h2_session
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0,session->c,
"h2_session: closing, writing eoc");
- h2_session_cleanup(session);
- return h2_conn_io_writeb(&session->io,
- h2_bucket_eoc_create(session->c->bucket_alloc,
- session));
+ h2_session_cleanup(session);
+ return h2_conn_io_close(&session->io, session);
}
static ssize_t stream_data_cb(nghttp2_session *ng2s,
@@ -1076,6 +1118,22 @@ static ssize_t stream_data_cb(nghttp2_se
}
if (eos) {
+ apr_table_t *trailers = h2_stream_get_trailers(stream);
+ if (trailers && !apr_is_empty_table(trailers)) {
+ h2_ngheader *nh;
+ int rv;
+
+ nh = h2_util_ngheader_make(stream->pool, trailers);
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ "h2_stream(%ld-%d): submit %d trailers",
+ session->id, (int)stream_id,(int) nh->nvlen);
+ rv = nghttp2_submit_trailer(ng2s, stream->id, nh->nv, nh->nvlen);
+ if (rv < 0) {
+ nread = rv;
+ }
+ *data_flags |= NGHTTP2_DATA_FLAG_NO_END_STREAM;
+ }
+
*data_flags |= NGHTTP2_DATA_FLAG_EOF;
}
@@ -1104,7 +1162,7 @@ static apr_status_t submit_response(h2_s
if (stream->submitted) {
rv = NGHTTP2_PROTOCOL_ERROR;
}
- else if (stream->response && stream->response->header) {
+ else if (stream->response && stream->response->headers) {
nghttp2_data_provider provider;
h2_response *response = stream->response;
h2_ngheader *ngh;
@@ -1118,7 +1176,7 @@ static apr_status_t submit_response(h2_s
session->id, stream->id, response->http_status);
ngh = h2_util_ngheader_make_res(stream->pool, response->http_status,
- response->header);
+ response->headers);
rv = nghttp2_submit_response(session->ngh2, response->stream_id,
ngh->nv, ngh->nvlen, &provider);
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_session.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_session.h?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_session.h (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_session.h Mon Nov 23 19:18:49 2015
@@ -148,12 +148,6 @@ apr_status_t h2_session_start(h2_session
apr_status_t h2_session_abort(h2_session *session, apr_status_t reason, int rv);
/**
- * Pass any buffered output data through the connection filters.
- * @param session the session to flush
- */
-apr_status_t h2_session_flush(h2_session *session);
-
-/**
* Called before a session gets destroyed, might flush output etc.
*/
apr_status_t h2_session_close(h2_session *session);
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_stream.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_stream.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_stream.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_stream.c Mon Nov 23 19:18:49 2015
@@ -223,7 +223,7 @@ apr_status_t h2_stream_set_response(h2_s
* as we want, since the lifetimes are the same and we are not freeing
* the ones in h2_mplx->io before this stream is done. */
H2_STREAM_OUT(APLOG_TRACE2, stream, "h2_stream set_response_pre");
- status = h2_util_move(stream->bbout, bb, -1, &move_all,
+ status = h2_util_move(stream->bbout, bb, 16 * 1024, &move_all,
"h2_stream_set_response");
H2_STREAM_OUT(APLOG_TRACE2, stream, "h2_stream set_response_post");
}
@@ -304,17 +304,22 @@ apr_status_t h2_stream_schedule(h2_strea
status = h2_mplx_process(stream->session->mplx, stream->id,
stream->request, eos, cmp, ctx);
stream->scheduled = 1;
+
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, stream->session->c,
+ "h2_stream(%ld-%d): scheduled %s %s://%s%s",
+ stream->session->id, stream->id,
+ stream->request->method, stream->request->scheme,
+ stream->request->authority, stream->request->path);
}
else {
h2_stream_rst(stream, H2_ERR_INTERNAL_ERROR);
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, stream->session->c,
+ "h2_stream(%ld-%d): RST=2 (internal err) %s %s://%s%s",
+ stream->session->id, stream->id,
+ stream->request->method, stream->request->scheme,
+ stream->request->authority, stream->request->path);
}
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, stream->session->c,
- "h2_stream(%ld-%d): scheduled %s %s://%s%s",
- stream->session->id, stream->id,
- stream->request->method, stream->request->scheme,
- stream->request->authority, stream->request->path);
-
return status;
}
@@ -365,6 +370,22 @@ static apr_status_t input_add_data(h2_st
return status;
}
+static int input_add_header(void *str, const char *key, const char *value)
+{
+ h2_stream *stream = str;
+ apr_status_t status = input_add_data(stream, key, strlen(key), 0);
+ if (status == APR_SUCCESS) {
+ status = input_add_data(stream, ": ", 2, 0);
+ if (status == APR_SUCCESS) {
+ status = input_add_data(stream, value, strlen(value), 0);
+ if (status == APR_SUCCESS) {
+ status = input_add_data(stream, "\r\n", 2, 0);
+ }
+ }
+ }
+ return (status == APR_SUCCESS);
+}
+
apr_status_t h2_stream_close_input(h2_stream *stream)
{
apr_status_t status = APR_SUCCESS;
@@ -381,7 +402,15 @@ apr_status_t h2_stream_close_input(h2_st
H2_STREAM_IN(APLOG_TRACE2, stream, "close_pre");
if (close_input(stream) && stream->bbin) {
if (stream->request->chunked) {
- status = input_add_data(stream, "0\r\n\r\n", 5, 0);
+ apr_table_t *trailers = stream->request->trailers;
+ if (trailers && !apr_is_empty_table(trailers)) {
+ status = input_add_data(stream, "0\r\n", 3, 0);
+ apr_table_do(input_add_header, stream, trailers, NULL);
+ status = input_add_data(stream, "\r\n", 2, 0);
+ }
+ else {
+ status = input_add_data(stream, "0\r\n\r\n", 5, 0);
+ }
}
if (status == APR_SUCCESS) {
@@ -447,6 +476,7 @@ apr_status_t h2_stream_prep_read(h2_stre
{
apr_status_t status = APR_SUCCESS;
const char *src;
+ apr_table_t *trailers = NULL;
int test_read = (*plen == 0);
if (stream->rst_error) {
@@ -461,19 +491,26 @@ apr_status_t h2_stream_prep_read(h2_stre
apr_brigade_cleanup(stream->bbout);
return h2_stream_prep_read(stream, plen, peos);
}
+ trailers = stream->response? stream->response->trailers : NULL;
}
else {
src = "mplx";
status = h2_mplx_out_readx(stream->session->mplx, stream->id,
- NULL, NULL, plen, peos);
+ NULL, NULL, plen, peos, &trailers);
+ if (trailers && stream->response) {
+ h2_response_set_trailers(stream->response, trailers);
+ }
}
+
if (!test_read && status == APR_SUCCESS && !*peos && !*plen) {
status = APR_EAGAIN;
}
+
H2_STREAM_OUT(APLOG_TRACE2, stream, "h2_stream prep_read_post");
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, stream->session->c,
- "h2_stream(%ld-%d): prep_read %s, len=%ld eos=%d",
- stream->session->id, stream->id, src, (long)*plen, *peos);
+ "h2_stream(%ld-%d): prep_read %s, len=%ld eos=%d, trailers=%s",
+ stream->session->id, stream->id, src, (long)*plen, *peos,
+ trailers? "yes" : "no");
return status;
}
@@ -482,6 +519,7 @@ apr_status_t h2_stream_readx(h2_stream *
apr_off_t *plen, int *peos)
{
apr_status_t status = APR_SUCCESS;
+ apr_table_t *trailers = NULL;
const char *src;
H2_STREAM_OUT(APLOG_TRACE2, stream, "h2_stream readx_pre");
@@ -503,14 +541,21 @@ apr_status_t h2_stream_readx(h2_stream *
else {
src = "mplx";
status = h2_mplx_out_readx(stream->session->mplx, stream->id,
- cb, ctx, plen, peos);
+ cb, ctx, plen, peos, &trailers);
+ }
+
+ if (trailers && stream->response) {
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, stream->session->c,
+ "h2_stream(%ld-%d): readx, saving trailers",
+ stream->session->id, stream->id);
+ h2_response_set_trailers(stream->response, trailers);
}
if (status == APR_SUCCESS && !*peos && !*plen) {
status = APR_EAGAIN;
}
- H2_STREAM_OUT(APLOG_TRACE2, stream, "h2_stream prep_readx_post");
+ H2_STREAM_OUT(APLOG_TRACE2, stream, "h2_stream readx_post");
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, stream->session->c,
"h2_stream(%ld-%d): readx %s, len=%ld eos=%d",
stream->session->id, stream->id, src, (long)*plen, *peos);
@@ -523,6 +568,7 @@ apr_status_t h2_stream_read_to(h2_stream
apr_off_t *plen, int *peos)
{
apr_status_t status = APR_SUCCESS;
+ apr_table_t *trailers = NULL;
H2_STREAM_OUT(APLOG_TRACE2, stream, "h2_stream read_to_pre");
if (stream->rst_error) {
@@ -533,7 +579,7 @@ apr_status_t h2_stream_read_to(h2_stream
apr_off_t tlen = *plen;
int eos;
status = h2_mplx_out_read_to(stream->session->mplx, stream->id,
- stream->bbout, &tlen, &eos);
+ stream->bbout, &tlen, &eos, &trailers);
}
if (status == APR_SUCCESS && !APR_BRIGADE_EMPTY(stream->bbout)) {
@@ -545,6 +591,13 @@ apr_status_t h2_stream_read_to(h2_stream
*peos = 0;
}
+ if (trailers && stream->response) {
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, stream->session->c,
+ "h2_stream(%ld-%d): read_to, saving trailers",
+ stream->session->id, stream->id);
+ h2_response_set_trailers(stream->response, trailers);
+ }
+
if (status == APR_SUCCESS && !*peos && !*plen) {
status = APR_EAGAIN;
}
@@ -610,3 +663,8 @@ apr_status_t h2_stream_submit_pushes(h2_
}
return status;
}
+
+apr_table_t *h2_stream_get_trailers(h2_stream *stream)
+{
+ return stream->response? stream->response->trailers : NULL;
+}
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_stream.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_stream.h?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_stream.h (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_stream.h Mon Nov 23 19:18:49 2015
@@ -290,4 +290,14 @@ int h2_stream_needs_submit(h2_stream *st
*/
apr_status_t h2_stream_submit_pushes(h2_stream *stream);
+/**
+ * Get optional trailers for this stream, may be NULL. Meaningful
+ * results can only be expected when the end of the response body has
+ * been reached.
+ *
+ * @param stream to ask for trailers
+ * @return trailers for NULL
+ */
+apr_table_t *h2_stream_get_trailers(h2_stream *stream);
+
#endif /* defined(__mod_h2__h2_stream__) */
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task.c Mon Nov 23 19:18:49 2015
@@ -113,6 +113,8 @@ void h2_task_register_hooks(void)
NULL, AP_FTYPE_NETWORK);
ap_register_output_filter("H1_TO_H2_RESP", h2_filter_read_response,
NULL, AP_FTYPE_PROTOCOL);
+ ap_register_output_filter("H2_TRAILERS", h2_response_trailers_filter,
+ NULL, AP_FTYPE_PROTOCOL);
}
static int h2_task_pre_conn(conn_rec* c, void *arg)
@@ -161,7 +163,7 @@ h2_task *h2_task_create(long session_id,
ap_log_perror(APLOG_MARK, APLOG_ERR, APR_ENOMEM, pool,
APLOGNO(02941) "h2_task(%ld-%d): create stream task",
session_id, req->id);
- h2_mplx_out_close(mplx, req->id);
+ h2_mplx_out_close(mplx, req->id, NULL);
return NULL;
}
@@ -228,8 +230,8 @@ apr_status_t h2_task_do(h2_task *task, h
apr_thread_cond_signal(task->io);
}
- h2_mplx_task_done(task->mplx, task->stream_id);
h2_worker_release_task(worker, task);
+ h2_mplx_task_done(task->mplx, task->stream_id);
return status;
}
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task_output.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task_output.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task_output.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task_output.c Mon Nov 23 19:18:49 2015
@@ -83,17 +83,31 @@ static apr_status_t open_if_needed(h2_ta
return APR_ECONNABORTED;
}
+ output->trailers_passed = !!response->trailers;
return h2_mplx_out_open(output->task->mplx, output->task->stream_id,
response, f, bb, output->task->io);
}
return APR_EOF;
}
+static apr_table_t *get_trailers(h2_task_output *output)
+{
+ if (!output->trailers_passed) {
+ h2_response *response = h2_from_h1_get_response(output->from_h1);
+ if (response->trailers) {
+ output->trailers_passed = 1;
+ return response->trailers;
+ }
+ }
+ return NULL;
+}
+
void h2_task_output_close(h2_task_output *output)
{
open_if_needed(output, NULL, NULL);
if (output->state != H2_TASK_OUT_DONE) {
- h2_mplx_out_close(output->task->mplx, output->task->stream_id);
+ h2_mplx_out_close(output->task->mplx, output->task->stream_id,
+ get_trailers(output));
output->state = H2_TASK_OUT_DONE;
}
}
@@ -111,6 +125,7 @@ apr_status_t h2_task_output_write(h2_tas
ap_filter_t* f, apr_bucket_brigade* bb)
{
apr_status_t status;
+
if (APR_BRIGADE_EMPTY(bb)) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, f->c,
"h2_task_output(%s): empty write", output->task->id);
@@ -124,9 +139,10 @@ apr_status_t h2_task_output_write(h2_tas
output->task->id);
return status;
}
+
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, f->c,
"h2_task_output(%s): write brigade", output->task->id);
return h2_mplx_out_write(output->task->mplx, output->task->stream_id,
- f, bb, output->task->io);
+ f, bb, get_trailers(output), output->task->io);
}
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task_output.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task_output.h?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task_output.h (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_task_output.h Mon Nov 23 19:18:49 2015
@@ -38,6 +38,7 @@ struct h2_task_output {
struct h2_task *task;
h2_task_output_state_t state;
struct h2_from_h1 *from_h1;
+ int trailers_passed;
};
h2_task_output *h2_task_output_create(struct h2_task *task, apr_pool_t *pool);
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_util.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_util.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_util.c Mon Nov 23 19:18:49 2015
@@ -834,6 +834,21 @@ static int add_table_header(void *ctx, c
}
+h2_ngheader *h2_util_ngheader_make(apr_pool_t *p, apr_table_t *header)
+{
+ h2_ngheader *ngh;
+ size_t n;
+
+ n = 0;
+ apr_table_do(count_header, &n, header, NULL);
+
+ ngh = apr_pcalloc(p, sizeof(h2_ngheader));
+ ngh->nv = apr_pcalloc(p, n * sizeof(nghttp2_nv));
+ apr_table_do(add_table_header, ngh, header, NULL);
+
+ return ngh;
+}
+
h2_ngheader *h2_util_ngheader_make_res(apr_pool_t *p,
int http_status,
apr_table_t *header)
@@ -879,3 +894,94 @@ h2_ngheader *h2_util_ngheader_make_req(a
return ngh;
}
+/*******************************************************************************
+ * header HTTP/1 <-> HTTP/2 conversions
+ ******************************************************************************/
+
+
+typedef struct {
+ const char *name;
+ size_t len;
+} literal;
+
+#define H2_DEF_LITERAL(n) { (n), (sizeof(n)-1) }
+#define H2_ALEN(a) (sizeof(a)/sizeof((a)[0]))
+#define H2_LIT_ARGS(a) (a),H2_ALEN(a)
+
+static literal IgnoredRequestHeaders[] = {
+ H2_DEF_LITERAL("host"),
+ H2_DEF_LITERAL("expect"),
+ H2_DEF_LITERAL("upgrade"),
+ H2_DEF_LITERAL("connection"),
+ H2_DEF_LITERAL("keep-alive"),
+ H2_DEF_LITERAL("http2-settings"),
+ H2_DEF_LITERAL("proxy-connection"),
+ H2_DEF_LITERAL("transfer-encoding"),
+};
+static literal IgnoredRequestTrailers[] = { /* Ignore, see rfc7230, ch. 4.1.2 */
+ H2_DEF_LITERAL("te"),
+ H2_DEF_LITERAL("host"),
+ H2_DEF_LITERAL("range"),
+ H2_DEF_LITERAL("cookie"),
+ H2_DEF_LITERAL("expect"),
+ H2_DEF_LITERAL("pragma"),
+ H2_DEF_LITERAL("max-forwards"),
+ H2_DEF_LITERAL("cache-control"),
+ H2_DEF_LITERAL("authorization"),
+ H2_DEF_LITERAL("content-length"),
+ H2_DEF_LITERAL("proxy-authorization"),
+};
+static literal IgnoredResponseTrailers[] = {
+ H2_DEF_LITERAL("age"),
+ H2_DEF_LITERAL("date"),
+ H2_DEF_LITERAL("vary"),
+ H2_DEF_LITERAL("cookie"),
+ H2_DEF_LITERAL("expires"),
+ H2_DEF_LITERAL("warning"),
+ H2_DEF_LITERAL("location"),
+ H2_DEF_LITERAL("retry-after"),
+ H2_DEF_LITERAL("cache-control"),
+ H2_DEF_LITERAL("www-authenticate"),
+ H2_DEF_LITERAL("proxy-authenticate"),
+};
+
+static int ignore_header(const literal *lits, size_t llen,
+ const char *name, size_t nlen)
+{
+ const literal *lit;
+ int i;
+
+ for (i = 0; i < llen; ++i) {
+ lit = &lits[i];
+ if (lit->len == nlen && !apr_strnatcasecmp(lit->name, name)) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int h2_req_ignore_header(const char *name, size_t len)
+{
+ return ignore_header(H2_LIT_ARGS(IgnoredRequestHeaders), name, len);
+}
+
+int h2_req_ignore_trailer(const char *name, size_t len)
+{
+ return (h2_req_ignore_header(name, len)
+ || ignore_header(H2_LIT_ARGS(IgnoredRequestTrailers), name, len));
+}
+
+int h2_res_ignore_trailer(const char *name, size_t len)
+{
+ return ignore_header(H2_LIT_ARGS(IgnoredResponseTrailers), name, len);
+}
+
+void h2_req_strip_ignored_header(apr_table_t *headers)
+{
+ int i;
+ for (i = 0; i < H2_ALEN(IgnoredRequestHeaders); ++i) {
+ apr_table_unset(headers, IgnoredRequestHeaders[i].name);
+ }
+}
+
+
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_util.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_util.h?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_util.h (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_util.h Mon Nov 23 19:18:49 2015
@@ -30,6 +30,11 @@ char *h2_strlwr(char *s);
void h2_util_camel_case_header(char *s, size_t len);
+int h2_req_ignore_header(const char *name, size_t len);
+int h2_req_ignore_trailer(const char *name, size_t len);
+void h2_req_strip_ignored_header(apr_table_t *headers);
+int h2_res_ignore_trailer(const char *name, size_t len);
+
/**
* Return != 0 iff the string s contains the token, as specified in
* HTTP header syntax, rfc7230.
@@ -75,6 +80,7 @@ typedef struct h2_ngheader {
apr_size_t nvlen;
} h2_ngheader;
+h2_ngheader *h2_util_ngheader_make(apr_pool_t *p, apr_table_t *header);
h2_ngheader *h2_util_ngheader_make_res(apr_pool_t *p,
int http_status,
apr_table_t *header);
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_version.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_version.h?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_version.h (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_version.h Mon Nov 23 19:18:49 2015
@@ -20,7 +20,7 @@
* @macro
* Version number of the h2 module as c string
*/
-#define MOD_HTTP2_VERSION "1.0.5-DEV"
+#define MOD_HTTP2_VERSION "1.0.6-DEV"
/**
* @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 0x010005
+#define MOD_HTTP2_VERSION_NUM 0x010006
#endif /* mod_h2_h2_version_h */
Modified: httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_worker.c?rev=1715925&r1=1715924&r2=1715925&view=diff
==============================================================================
--- httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_worker.c (original)
+++ httpd/httpd/branches/2.4-http2-alpha/modules/http2/h2_worker.c Mon Nov 23 19:18:49 2015
@@ -96,8 +96,9 @@ h2_worker *h2_worker_create(int id,
apr_allocator_t *allocator = NULL;
apr_pool_t *pool = NULL;
h2_worker *w;
+ apr_status_t status;
- apr_status_t status = apr_allocator_create(&allocator);
+ status = apr_allocator_create(&allocator);
if (status != APR_SUCCESS) {
return NULL;
}
@@ -126,7 +127,6 @@ h2_worker *h2_worker_create(int id,
apr_pool_pre_cleanup_register(w->pool, w, cleanup_join_thread);
apr_thread_create(&w->thread, attr, execute, w, w->pool);
- apr_pool_create(&w->task_pool, w->pool);
}
return w;
}
@@ -167,7 +167,11 @@ h2_task *h2_worker_create_task(h2_worker
/* 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);
+ }
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;