From 85fb49b1d108a7fd8a762b685dd0e6386f8e2ae3 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 4 Oct 2016 08:55:08 +0000 Subject: [PATCH] mod_http2: replacing module internal hook with own impl as the former does not compile on Windows git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1763246 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http2/h2_bucket_beam.c | 37 ++++++++++++++++++++++++++-------- modules/http2/h2_bucket_beam.h | 8 +++++--- modules/http2/h2_conn.c | 4 ++-- modules/http2/h2_filter.c | 2 +- modules/http2/h2_h2.c | 4 ++-- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/modules/http2/h2_bucket_beam.c b/modules/http2/h2_bucket_beam.c index 7860d26170..4397e19c76 100644 --- a/modules/http2/h2_bucket_beam.c +++ b/modules/http2/h2_bucket_beam.c @@ -170,14 +170,35 @@ const apr_bucket_type_t h2_bucket_type_beam = { /******************************************************************************* * h2_blist, a brigade without allocations ******************************************************************************/ + +static apr_array_header_t *beamers; -APR_HOOK_STRUCT( - APR_HOOK_LINK(beam_bucket) -) -AP_IMPLEMENT_HOOK_RUN_FIRST(apr_bucket *, beam_bucket, - (h2_bucket_beam *beam, apr_bucket_brigade *dest, - const apr_bucket *src), - (beam, dest, src), NULL) +void h2_register_bucket_beamer(h2_bucket_beamer *beamer) +{ + if (!beamers) { + beamers = apr_array_make(apr_hook_global_pool, 10, + sizeof(h2_bucket_beamer*)); + } + APR_ARRAY_PUSH(beamers, h2_bucket_beamer*) = beamer; +} + +static apr_bucket *h2_beam_bucket(h2_bucket_beam *beam, + apr_bucket_brigade *dest, + const apr_bucket *src) +{ + apr_bucket *b = NULL; + int i; + if (beamers) { + for (i = 0; i < beamers->nelts && b == NULL; ++i) { + h2_bucket_beamer *beamer; + + beamer = APR_ARRAY_IDX(beamers, i, h2_bucket_beamer*); + b = beamer(beam, dest, src); + } + } + return b; +} + apr_size_t h2_util_bl_print(char *buffer, apr_size_t bmax, const char *tag, const char *sep, @@ -860,7 +881,7 @@ transfer: ++transferred; } else { - bgreen = ap_run_beam_bucket(beam, bb, bred); + bgreen = h2_beam_bucket(beam, bb, bred); while (bgreen && bgreen != APR_BRIGADE_SENTINEL(bb)) { ++transferred; remain -= bgreen->length; diff --git a/modules/http2/h2_bucket_beam.h b/modules/http2/h2_bucket_beam.h index db46baacd6..80fa9e127d 100644 --- a/modules/http2/h2_bucket_beam.h +++ b/modules/http2/h2_bucket_beam.h @@ -373,8 +373,10 @@ int h2_beam_was_received(h2_bucket_beam *beam); apr_size_t h2_beam_get_files_beamed(h2_bucket_beam *beam); -AP_DECLARE_HOOK(apr_bucket *, beam_bucket, - (h2_bucket_beam *beam, apr_bucket_brigade *dest, - const apr_bucket *src)) +typedef apr_bucket *h2_bucket_beamer(h2_bucket_beam *beam, + apr_bucket_brigade *dest, + const apr_bucket *src); + +void h2_register_bucket_beamer(h2_bucket_beamer *beamer); #endif /* h2_bucket_beam_h */ diff --git a/modules/http2/h2_conn.c b/modules/http2/h2_conn.c index c2e8e0ef34..675ddeb266 100644 --- a/modules/http2/h2_conn.c +++ b/modules/http2/h2_conn.c @@ -290,8 +290,8 @@ conn_rec *h2_slave_create(conn_rec *master, apr_uint32_t slave_id, * many streams. */ l = master->id; - if (sizeof(long) >= 8 && l < APR_UINT32_MAX) { - c->id = l|(((unsigned long)slave_id) << 32); + if (sizeof(unsigned long) >= 8 && l < APR_UINT32_MAX) { + c->id = l|((unsigned long)slave_id << 32); } else { c->id = l^(~slave_id); diff --git a/modules/http2/h2_filter.c b/modules/http2/h2_filter.c index 6d9cee16f5..a4ef20d7e9 100644 --- a/modules/http2/h2_filter.c +++ b/modules/http2/h2_filter.c @@ -238,7 +238,7 @@ apr_status_t h2_bucket_observer_fire(apr_bucket *b, h2_bucket_event event) } const apr_bucket_type_t h2_bucket_type_observer = { - "H2LAZY", 5, APR_BUCKET_METADATA, + "H2OBS", 5, APR_BUCKET_METADATA, bucket_destroy, bucket_read, apr_bucket_setaside_noop, diff --git a/modules/http2/h2_h2.c b/modules/http2/h2_h2.c index 80e1afadfb..39707de4b5 100644 --- a/modules/http2/h2_h2.c +++ b/modules/http2/h2_h2.c @@ -574,8 +574,8 @@ void h2_h2_register_hooks(void) ap_hook_fixups(h2_h2_late_fixups, NULL, NULL, APR_HOOK_LAST); /* special bucket type transfer through a h2_bucket_beam */ - ap_hook_beam_bucket(h2_bucket_observer_beam, NULL, NULL, APR_HOOK_MIDDLE); - ap_hook_beam_bucket(h2_bucket_headers_beam, NULL, NULL, APR_HOOK_MIDDLE); + h2_register_bucket_beamer(h2_bucket_headers_beam); + h2_register_bucket_beamer(h2_bucket_observer_beam); } int h2_h2_process_conn(conn_rec* c) -- 2.40.0