From 37e52e04153b95d2d98c6de19e7baa8e3383cff1 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Thu, 6 Oct 2016 15:39:42 +0000 Subject: [PATCH] Merge of r1763613 from trunk: mod_http2: fixes compilation error on 32bit systems when generating a slave connection id git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1763614 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http2/h2_conn.c | 13 ++++++++++--- modules/http2/h2_from_h1.c | 8 ++++---- modules/http2/h2_from_h1.h | 5 +---- modules/http2/h2_ngn_shed.c | 4 ++-- modules/http2/h2_task.c | 8 ++++---- modules/http2/h2_task.h | 8 ++++---- modules/http2/h2_version.h | 4 ++-- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/modules/http2/h2_conn.c b/modules/http2/h2_conn.c index 675ddeb266..1d96e4c6aa 100644 --- a/modules/http2/h2_conn.c +++ b/modules/http2/h2_conn.c @@ -247,7 +247,8 @@ conn_rec *h2_slave_create(conn_rec *master, apr_uint32_t slave_id, apr_pool_t *pool; conn_rec *c; void *cfg; - unsigned long l; + unsigned int free_bits; + unsigned long l, lor; AP_DEBUG_ASSERT(master); ap_log_cerror(APLOG_MARK, APLOG_TRACE3, 0, master, @@ -290,12 +291,18 @@ conn_rec *h2_slave_create(conn_rec *master, apr_uint32_t slave_id, * many streams. */ l = master->id; + lor = 0; if (sizeof(unsigned long) >= 8 && l < APR_UINT32_MAX) { - c->id = l|((unsigned long)slave_id << 32); + free_bits = 32; } else { - c->id = l^(~slave_id); + /* Assume that we never encounter ranges stream ids where this + * leads to many collisions. With 32 bit longs, we have a hard time + * to make server wide unique ids. */ + free_bits = 16; + lor= (1 << 31); } + c->id = (l^((unsigned long)slave_id << free_bits))|lor; c->master = master; c->pool = pool; c->conn_config = ap_create_conn_config(pool); diff --git a/modules/http2/h2_from_h1.c b/modules/http2/h2_from_h1.c index b7429dc7d4..899512233e 100644 --- a/modules/http2/h2_from_h1.c +++ b/modules/http2/h2_from_h1.c @@ -113,8 +113,8 @@ static void fix_vary(request_rec *r) } } -void h2_from_h1_set_basic_http_header(apr_table_t *headers, request_rec *r, - apr_pool_t *pool) +static void set_basic_http_header(apr_table_t *headers, request_rec *r, + apr_pool_t *pool) { char *date = NULL; const char *proxy_date = NULL; @@ -272,7 +272,7 @@ static h2_headers *create_response(h2_task *task, request_rec *r) headers = apr_table_make(r->pool, 10); - h2_from_h1_set_basic_http_header(headers, r, r->pool); + set_basic_http_header(headers, r, r->pool); if (r->status == HTTP_NOT_MODIFIED) { apr_table_do((int (*)(void *, const char *, const char *)) copy_header, (void *) headers, r->headers_out, @@ -296,7 +296,7 @@ static h2_headers *create_response(h2_task *task, request_rec *r) return h2_headers_rcreate(r, r->status, headers, r->pool); } -apr_status_t h2_headers_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) +apr_status_t h2_filter_headers_out(ap_filter_t *f, apr_bucket_brigade *bb) { h2_task *task = f->ctx; request_rec *r = f->r; diff --git a/modules/http2/h2_from_h1.h b/modules/http2/h2_from_h1.h index 9215539668..08101088d5 100644 --- a/modules/http2/h2_from_h1.h +++ b/modules/http2/h2_from_h1.h @@ -33,7 +33,7 @@ struct h2_headers; struct h2_task; -apr_status_t h2_headers_output_filter(ap_filter_t *f, apr_bucket_brigade *bb); +apr_status_t h2_filter_headers_out(ap_filter_t *f, apr_bucket_brigade *bb); apr_status_t h2_filter_request_in(ap_filter_t* f, apr_bucket_brigade* brigade, @@ -43,7 +43,4 @@ apr_status_t h2_filter_request_in(ap_filter_t* f, apr_status_t h2_filter_trailers_out(ap_filter_t *f, apr_bucket_brigade *bb); -void h2_from_h1_set_basic_http_header(apr_table_t *headers, request_rec *r, - apr_pool_t *pool); - #endif /* defined(__mod_h2__h2_from_h1__) */ diff --git a/modules/http2/h2_ngn_shed.c b/modules/http2/h2_ngn_shed.c index 6be6d24d71..8dae7b8fa5 100644 --- a/modules/http2/h2_ngn_shed.c +++ b/modules/http2/h2_ngn_shed.c @@ -183,7 +183,7 @@ apr_status_t h2_ngn_shed_push_request(h2_ngn_shed *shed, const char *ngn_type, ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, task->c, "h2_ngn_shed(%ld): pushing request %s to %s", shed->c->id, task->id, ngn->id); - if (!h2_task_is_detached(task)) { + if (!h2_task_has_thawed(task)) { h2_task_freeze(task); } ngn_add_task(ngn, task, r); @@ -232,7 +232,7 @@ static h2_ngn_entry *pop_detached(h2_req_engine *ngn) for (entry = H2_REQ_ENTRIES_FIRST(&ngn->entries); entry != H2_REQ_ENTRIES_SENTINEL(&ngn->entries); entry = H2_NGN_ENTRY_NEXT(entry)) { - if (h2_task_is_detached(entry->task) + if (h2_task_has_thawed(entry->task) || (entry->task->engine == ngn)) { /* The task hosting this engine can always be pulled by it. * For other task, they need to become detached, e.g. no longer diff --git a/modules/http2/h2_task.c b/modules/http2/h2_task.c index 773b3768cd..d6f1ff2377 100644 --- a/modules/http2/h2_task.c +++ b/modules/http2/h2_task.c @@ -492,7 +492,7 @@ void h2_task_register_hooks(void) NULL, AP_FTYPE_PROTOCOL); ap_register_input_filter("H2_REQUEST", h2_filter_request_in, NULL, AP_FTYPE_PROTOCOL); - ap_register_output_filter("H2_RESPONSE", h2_headers_output_filter, + ap_register_output_filter("H2_RESPONSE", h2_filter_headers_out, NULL, AP_FTYPE_PROTOCOL); ap_register_output_filter("H2_TRAILERS_OUT", h2_filter_trailers_out, NULL, AP_FTYPE_PROTOCOL); @@ -705,11 +705,11 @@ apr_status_t h2_task_thaw(h2_task *task) ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, task->c, APLOGNO(03407) "h2_task(%s), thawed", task->id); } - task->detached = 1; + task->thawed = 1; return APR_SUCCESS; } -int h2_task_is_detached(h2_task *task) +int h2_task_has_thawed(h2_task *task) { - return task->detached; + return task->thawed; } diff --git a/modules/http2/h2_task.h b/modules/http2/h2_task.h index 9c81a8693a..f607c88438 100644 --- a/modules/http2/h2_task.h +++ b/modules/http2/h2_task.h @@ -77,9 +77,9 @@ struct h2_task { unsigned int filters_set : 1; unsigned int frozen : 1; - unsigned int detached : 1; - unsigned int worker_started : 1; /* h2_worker started processing for this io */ - unsigned int worker_done : 1; /* h2_worker finished for this io */ + unsigned int thawed : 1; + unsigned int worker_started : 1; /* h2_worker started processing */ + unsigned int worker_done : 1; /* h2_worker finished */ apr_time_t started_at; /* when processing started */ apr_time_t done_at; /* when processing was done */ @@ -116,6 +116,6 @@ extern APR_OPTIONAL_FN_TYPE(ap_logio_add_bytes_out) *h2_task_logio_add_bytes_out apr_status_t h2_task_freeze(h2_task *task); apr_status_t h2_task_thaw(h2_task *task); -int h2_task_is_detached(h2_task *task); +int h2_task_has_thawed(h2_task *task); #endif /* defined(__mod_h2__h2_task__) */ diff --git a/modules/http2/h2_version.h b/modules/http2/h2_version.h index 3a10748427..b7c051e22e 100644 --- a/modules/http2/h2_version.h +++ b/modules/http2/h2_version.h @@ -26,7 +26,7 @@ * @macro * Version number of the http2 module as c string */ -#define MOD_HTTP2_VERSION "1.7.1" +#define MOD_HTTP2_VERSION "1.7.2" /** * @macro @@ -34,7 +34,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 0x010701 +#define MOD_HTTP2_VERSION_NUM 0x010702 #endif /* mod_h2_h2_version_h */ -- 2.40.0