Changes with Apache 2.4.24
+ *) mod_proxy_http2: fixed duplicate symbols with mod_http2.
+ [Stefan Eissing]
+
*) mod_http2: rewrite of how responses and trailers are transferred between
master and slave connection. Reduction of internal states for tasks
and streams, stability. Heuristic id generation for slave connections
@echo $(DL) h2_log2,$(DL) >> $@
@echo $(DL) h2_proxy_res_ignore_header,$(DL) >> $@
@echo $(DL) h2_headers_add_h1,$(DL) >> $@
- @echo $(DL) h2_req_create,$(DL) >> $@
- @echo $(DL) h2_req_createn,$(DL) >> $@
- @echo $(DL) h2_req_make,$(DL) >> $@
- @echo $(DL) h2_util_camel_case_header,$(DL) >> $@
- @echo $(DL) h2_util_frame_print,$(DL) >> $@
- @echo $(DL) h2_util_ngheader_make_req,$(DL) >> $@
@echo $(DL) nghttp2_is_fatal,$(DL) >> $@
@echo $(DL) nghttp2_option_del,$(DL) >> $@
@echo $(DL) nghttp2_option_new,$(DL) >> $@
/* Try to get rid of streams that occupy workers. Look for safe requests
* that are repeatable. If none found, fail the connection.
*/
- n = (m->workers_busy - m->workers_limit - h2_ihash_count(m->redo_tasks));
+ n = (m->workers_busy - m->workers_limit - (int)h2_ihash_count(m->redo_tasks));
while (n > 0 && (task = get_latest_repeatable_unsubmitted_task(m))) {
h2_task_rst(task, H2_ERR_CANCEL);
h2_ihash_add(m->redo_tasks, task);
const char *url;
request_rec *r;
- h2_request *req;
+ h2_proxy_request *req;
int standalone;
h2_stream_state_t state;
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
"proxy_session(%s): pool cleanup, state=%d, streams=%d",
session->id, session->state,
- (int)h2_ihash_count(session->streams));
+ (int)h2_proxy_ihash_count(session->streams));
session->aborted = 1;
dispatch_event(session, H2_PROXYS_EV_PRE_CLOSE, 0, NULL);
nghttp2_session_del(session->ngh2);
if (APLOGcdebug(session->c)) {
char buffer[256];
- h2_util_frame_print(frame, buffer, sizeof(buffer)/sizeof(buffer[0]));
+ h2_proxy_util_frame_print(frame, buffer, sizeof(buffer)/sizeof(buffer[0]));
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03341)
"h2_proxy_session(%s): recv FRAME[%s]",
session->id, buffer);
if (APLOGcdebug(session->c)) {
char buffer[256];
- h2_util_frame_print(frame, buffer, sizeof(buffer)/sizeof(buffer[0]));
+ h2_proxy_util_frame_print(frame, buffer, sizeof(buffer)/sizeof(buffer[0]));
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03343)
"h2_proxy_session(%s): sent FRAME[%s]",
session->id, buffer);
char *hname, *hvalue;
hname = apr_pstrndup(stream->pool, n, nlen);
- h2_util_camel_case_header(hname, nlen);
+ h2_proxy_util_camel_case_header(hname, nlen);
hvalue = apr_pstrndup(stream->pool, v, vlen);
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, stream->session->c,
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03360)
"h2_proxy_session(%s): stream=%d, closed, err=%d",
session->id, stream_id, error_code);
- stream = h2_ihash_get(session->streams, stream_id);
+ stream = h2_proxy_ihash_get(session->streams, stream_id);
if (stream) {
stream->error_code = error_code;
}
"h2_proxy_stream(%s-%d): suspending",
stream->session->id, stream_id);
stream->suspended = 1;
- h2_iq_add(stream->session->suspended, stream->id, NULL, NULL);
+ h2_proxy_iq_add(stream->session->suspended, stream->id, NULL, NULL);
return NGHTTP2_ERR_DEFERRED;
}
else {
session->state = H2_PROXYS_ST_INIT;
session->window_bits_stream = window_bits_stream;
session->window_bits_connection = window_bits_connection;
- session->streams = h2_ihash_create(pool, offsetof(h2_proxy_stream, id));
- session->suspended = h2_iq_create(pool, 5);
+ session->streams = h2_proxy_ihash_create(pool, offsetof(h2_proxy_stream, id));
+ session->suspended = h2_proxy_iq_create(pool, 5);
session->done = done;
session->input = apr_brigade_create(session->pool, session->c->bucket_alloc);
stream->input = apr_brigade_create(stream->pool, session->c->bucket_alloc);
stream->output = apr_brigade_create(stream->pool, session->c->bucket_alloc);
- stream->req = h2_req_create(1, stream->pool, 0);
+ stream->req = h2_proxy_req_create(1, stream->pool, 0);
status = apr_uri_parse(stream->pool, url, &puri);
if (status != APR_SUCCESS)
authority = apr_psprintf(stream->pool, "%s:%d", authority, puri.port);
}
path = apr_uri_unparse(stream->pool, &puri, APR_URI_UNP_OMITSITEPART);
- h2_req_make(stream->req, stream->pool, r->method, scheme,
+ h2_proxy_req_make(stream->req, stream->pool, r->method, scheme,
authority, path, r->headers_in);
/* Tuck away all already existing cookies */
static apr_status_t submit_stream(h2_proxy_session *session, h2_proxy_stream *stream)
{
- h2_ngheader *hd;
+ h2_proxy_ngheader *hd;
nghttp2_data_provider *pp = NULL;
nghttp2_data_provider provider;
int rv;
if (rv > 0) {
stream->id = rv;
stream->state = H2_STREAM_ST_OPEN;
- h2_ihash_add(session->streams, stream);
+ h2_proxy_ihash_add(session->streams, stream);
dispatch_event(session, H2_PROXYS_EV_STREAM_SUBMITTED, rv, NULL);
return APR_SUCCESS;
"h2_proxy_stream(%s-%d): resuming",
session->id, stream_id);
stream->suspended = 0;
- h2_iq_remove(session->suspended, stream_id);
+ h2_proxy_iq_remove(session->suspended, stream_id);
nghttp2_session_resume_data(session->ngh2, stream_id);
dispatch_event(session, H2_PROXYS_EV_STREAM_RESUMED, 0, NULL);
check_suspended(session);
ap_log_cerror(APLOG_MARK, APLOG_WARNING, status, session->c,
APLOGNO(03382) "h2_proxy_stream(%s-%d): check input",
session->id, stream_id);
- h2_iq_remove(session->suspended, stream_id);
+ h2_proxy_iq_remove(session->suspended, stream_id);
dispatch_event(session, H2_PROXYS_EV_STREAM_RESUMED, 0, NULL);
check_suspended(session);
return APR_SUCCESS;
}
else {
/* gone? */
- h2_iq_remove(session->suspended, stream_id);
+ h2_proxy_iq_remove(session->suspended, stream_id);
check_suspended(session);
return APR_SUCCESS;
}
{
switch (session->state) {
case H2_PROXYS_ST_INIT:
- if (h2_ihash_empty(session->streams)) {
+ if (h2_proxy_ihash_empty(session->streams)) {
transit(session, "init", H2_PROXYS_ST_IDLE);
}
else {
* CPU cycles. Ideally, we'd like to do a blocking read, but that
* is not possible if we have scheduled tasks and wait
* for them to produce something. */
- if (h2_ihash_empty(session->streams)) {
+ if (h2_proxy_ihash_empty(session->streams)) {
if (!is_accepting_streams(session)) {
/* We are no longer accepting new streams and have
* finished processing existing ones. Time to leave. */
}
stream->state = H2_STREAM_ST_CLOSED;
- h2_ihash_remove(session->streams, stream_id);
- h2_iq_remove(session->suspended, stream_id);
+ h2_proxy_ihash_remove(session->streams, stream_id);
+ h2_proxy_iq_remove(session->suspended, stream_id);
if (session->done) {
session->done(session, stream->r, complete, touched);
}
void h2_proxy_session_cleanup(h2_proxy_session *session,
h2_proxy_request_done *done)
{
- if (session->streams && !h2_ihash_empty(session->streams)) {
+ if (session->streams && !h2_proxy_ihash_empty(session->streams)) {
cleanup_iter_ctx ctx;
ctx.session = session;
ctx.done = done;
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03366)
"h2_proxy_session(%s): terminated, %d streams unfinished",
- session->id, (int)h2_ihash_count(session->streams));
- h2_ihash_iter(session->streams, done_iter, &ctx);
- h2_ihash_clear(session->streams);
+ session->id, (int)h2_proxy_ihash_count(session->streams));
+ h2_proxy_ihash_iter(session->streams, done_iter, &ctx);
+ h2_proxy_ihash_clear(session->streams);
}
}
void h2_proxy_session_update_window(h2_proxy_session *session,
conn_rec *c, apr_off_t bytes)
{
- if (session->streams && !h2_ihash_empty(session->streams)) {
+ if (session->streams && !h2_proxy_ihash_empty(session->streams)) {
win_update_ctx ctx;
ctx.session = session;
ctx.c = c;
ctx.bytes = bytes;
ctx.updated = 0;
- h2_ihash_iter(session->streams, win_update_iter, &ctx);
+ h2_proxy_ihash_iter(session->streams, win_update_iter, &ctx);
if (!ctx.updated) {
/* could not find the stream any more, possibly closed, update
#include <nghttp2/nghttp2.h>
-struct h2_iqueue;
-struct h2_ihash_t;
+struct h2_proxy_iqueue;
+struct h2_proxy_ihash_t;
typedef enum {
H2_PROXYS_ST_INIT, /* send initial SETTINGS, etc. */
h2_proxys_state state;
apr_interval_time_t wait_timeout;
- struct h2_ihash_t *streams;
- struct h2_iqueue *suspended;
+ struct h2_proxy_ihash_t *streams;
+ struct h2_proxy_iqueue *suspended;
apr_size_t remote_max_concurrent;
int last_stream_id; /* last stream id processed by backend, or 0 */
#include "h2_proxy_util.h"
/* h2_log2(n) iff n is a power of 2 */
-unsigned char h2_log2(int n)
+unsigned char h2_proxy_log2(int n)
{
int lz = 0;
if (!n) {
/*******************************************************************************
* ihash - hash for structs with int identifier
******************************************************************************/
-struct h2_ihash_t {
+struct h2_proxy_ihash_t {
apr_hash_t *hash;
size_t ioff;
};
return (unsigned int)(*((int*)key));
}
-h2_ihash_t *h2_ihash_create(apr_pool_t *pool, size_t offset_of_int)
+h2_proxy_ihash_t *h2_proxy_ihash_create(apr_pool_t *pool, size_t offset_of_int)
{
- h2_ihash_t *ih = apr_pcalloc(pool, sizeof(h2_ihash_t));
+ h2_proxy_ihash_t *ih = apr_pcalloc(pool, sizeof(h2_proxy_ihash_t));
ih->hash = apr_hash_make_custom(pool, ihash);
ih->ioff = offset_of_int;
return ih;
}
-size_t h2_ihash_count(h2_ihash_t *ih)
+size_t h2_proxy_ihash_count(h2_proxy_ihash_t *ih)
{
return apr_hash_count(ih->hash);
}
-int h2_ihash_empty(h2_ihash_t *ih)
+int h2_proxy_ihash_empty(h2_proxy_ihash_t *ih)
{
return apr_hash_count(ih->hash) == 0;
}
-void *h2_ihash_get(h2_ihash_t *ih, int id)
+void *h2_proxy_ihash_get(h2_proxy_ihash_t *ih, int id)
{
return apr_hash_get(ih->hash, &id, sizeof(id));
}
typedef struct {
- h2_ihash_iter_t *iter;
+ h2_proxy_ihash_iter_t *iter;
void *ctx;
} iter_ctx;
return ictx->iter(ictx->ctx, (void*)val); /* why is this passed const?*/
}
-int h2_ihash_iter(h2_ihash_t *ih, h2_ihash_iter_t *fn, void *ctx)
+int h2_proxy_ihash_iter(h2_proxy_ihash_t *ih, h2_proxy_ihash_iter_t *fn, void *ctx)
{
iter_ctx ictx;
ictx.iter = fn;
return apr_hash_do(ihash_iter, &ictx, ih->hash);
}
-void h2_ihash_add(h2_ihash_t *ih, void *val)
+void h2_proxy_ihash_add(h2_proxy_ihash_t *ih, void *val)
{
apr_hash_set(ih->hash, ((char *)val + ih->ioff), sizeof(int), val);
}
-void h2_ihash_remove(h2_ihash_t *ih, int id)
+void h2_proxy_ihash_remove(h2_proxy_ihash_t *ih, int id)
{
apr_hash_set(ih->hash, &id, sizeof(id), NULL);
}
-void h2_ihash_remove_val(h2_ihash_t *ih, void *val)
+void h2_proxy_ihash_remove_val(h2_proxy_ihash_t *ih, void *val)
{
int id = *((int*)((char *)val + ih->ioff));
apr_hash_set(ih->hash, &id, sizeof(id), NULL);
}
-void h2_ihash_clear(h2_ihash_t *ih)
+void h2_proxy_ihash_clear(h2_proxy_ihash_t *ih)
{
apr_hash_clear(ih->hash);
}
typedef struct {
- h2_ihash_t *ih;
+ h2_proxy_ihash_t *ih;
void **buffer;
size_t max;
size_t len;
return 0;
}
-size_t h2_ihash_shift(h2_ihash_t *ih, void **buffer, size_t max)
+size_t h2_proxy_ihash_shift(h2_proxy_ihash_t *ih, void **buffer, size_t max)
{
collect_ctx ctx;
size_t i;
ctx.buffer = buffer;
ctx.max = max;
ctx.len = 0;
- h2_ihash_iter(ih, collect_iter, &ctx);
+ h2_proxy_ihash_iter(ih, collect_iter, &ctx);
for (i = 0; i < ctx.len; ++i) {
- h2_ihash_remove_val(ih, buffer[i]);
+ h2_proxy_ihash_remove_val(ih, buffer[i]);
}
return ctx.len;
}
typedef struct {
- h2_ihash_t *ih;
+ h2_proxy_ihash_t *ih;
int *buffer;
size_t max;
size_t len;
return 0;
}
-size_t h2_ihash_ishift(h2_ihash_t *ih, int *buffer, size_t max)
+size_t h2_proxy_ihash_ishift(h2_proxy_ihash_t *ih, int *buffer, size_t max)
{
icollect_ctx ctx;
size_t i;
ctx.buffer = buffer;
ctx.max = max;
ctx.len = 0;
- h2_ihash_iter(ih, icollect_iter, &ctx);
+ h2_proxy_ihash_iter(ih, icollect_iter, &ctx);
for (i = 0; i < ctx.len; ++i) {
- h2_ihash_remove(ih, buffer[i]);
+ h2_proxy_ihash_remove(ih, buffer[i]);
}
return ctx.len;
}
* iqueue - sorted list of int
******************************************************************************/
-static void iq_grow(h2_iqueue *q, int nlen);
-static void iq_swap(h2_iqueue *q, int i, int j);
-static int iq_bubble_up(h2_iqueue *q, int i, int top,
- h2_iq_cmp *cmp, void *ctx);
-static int iq_bubble_down(h2_iqueue *q, int i, int bottom,
- h2_iq_cmp *cmp, void *ctx);
+static void iq_grow(h2_proxy_iqueue *q, int nlen);
+static void iq_swap(h2_proxy_iqueue *q, int i, int j);
+static int iq_bubble_up(h2_proxy_iqueue *q, int i, int top,
+ h2_proxy_iq_cmp *cmp, void *ctx);
+static int iq_bubble_down(h2_proxy_iqueue *q, int i, int bottom,
+ h2_proxy_iq_cmp *cmp, void *ctx);
-h2_iqueue *h2_iq_create(apr_pool_t *pool, int capacity)
+h2_proxy_iqueue *h2_proxy_iq_create(apr_pool_t *pool, int capacity)
{
- h2_iqueue *q = apr_pcalloc(pool, sizeof(h2_iqueue));
+ h2_proxy_iqueue *q = apr_pcalloc(pool, sizeof(h2_proxy_iqueue));
if (q) {
q->pool = pool;
iq_grow(q, capacity);
return q;
}
-int h2_iq_empty(h2_iqueue *q)
+int h2_proxy_iq_empty(h2_proxy_iqueue *q)
{
return q->nelts == 0;
}
-int h2_iq_count(h2_iqueue *q)
+int h2_proxy_iq_count(h2_proxy_iqueue *q)
{
return q->nelts;
}
-void h2_iq_add(h2_iqueue *q, int sid, h2_iq_cmp *cmp, void *ctx)
+void h2_proxy_iq_add(h2_proxy_iqueue *q, int sid, h2_proxy_iq_cmp *cmp, void *ctx)
{
int i;
}
}
-int h2_iq_remove(h2_iqueue *q, int sid)
+int h2_proxy_iq_remove(h2_proxy_iqueue *q, int sid)
{
int i;
for (i = 0; i < q->nelts; ++i) {
return 0;
}
-void h2_iq_clear(h2_iqueue *q)
+void h2_proxy_iq_clear(h2_proxy_iqueue *q)
{
q->nelts = 0;
}
-void h2_iq_sort(h2_iqueue *q, h2_iq_cmp *cmp, void *ctx)
+void h2_proxy_iq_sort(h2_proxy_iqueue *q, h2_proxy_iq_cmp *cmp, void *ctx)
{
/* Assume that changes in ordering are minimal. This needs,
* best case, q->nelts - 1 comparisons to check that nothing
}
-int h2_iq_shift(h2_iqueue *q)
+int h2_proxy_iq_shift(h2_proxy_iqueue *q)
{
int sid;
return sid;
}
-static void iq_grow(h2_iqueue *q, int nlen)
+static void iq_grow(h2_proxy_iqueue *q, int nlen)
{
if (nlen > q->nalloc) {
int *nq = apr_pcalloc(q->pool, sizeof(int) * nlen);
}
}
-static void iq_swap(h2_iqueue *q, int i, int j)
+static void iq_swap(h2_proxy_iqueue *q, int i, int j)
{
int x = q->elts[i];
q->elts[i] = q->elts[j];
q->elts[j] = x;
}
-static int iq_bubble_up(h2_iqueue *q, int i, int top,
- h2_iq_cmp *cmp, void *ctx)
+static int iq_bubble_up(h2_proxy_iqueue *q, int i, int top,
+ h2_proxy_iq_cmp *cmp, void *ctx)
{
int prev;
while (((prev = (q->nalloc + i - 1) % q->nalloc), i != top)
return i;
}
-static int iq_bubble_down(h2_iqueue *q, int i, int bottom,
- h2_iq_cmp *cmp, void *ctx)
+static int iq_bubble_down(h2_proxy_iqueue *q, int i, int bottom,
+ h2_proxy_iq_cmp *cmp, void *ctx)
{
int next;
while (((next = (q->nalloc + i + 1) % q->nalloc), i != bottom)
}
/*******************************************************************************
- * h2_ngheader
+ * h2_proxy_ngheader
******************************************************************************/
#define H2_HD_MATCH_LIT_CS(l, name) \
((strlen(name) == sizeof(l) - 1) && !apr_strnatcasecmp(l, name))
#define NV_ADD_LIT_CS(nv, k, v) add_header(nv, k, sizeof(k) - 1, v, strlen(v))
#define NV_ADD_CS_CS(nv, k, v) add_header(nv, k, strlen(k), v, strlen(v))
-static int add_header(h2_ngheader *ngh,
+static int add_header(h2_proxy_ngheader *ngh,
const char *key, size_t key_len,
const char *value, size_t val_len)
{
return 1;
}
-h2_ngheader *h2_util_ngheader_make_req(apr_pool_t *p,
- const struct h2_request *req)
+h2_proxy_ngheader *h2_util_ngheader_make_req(apr_pool_t *p,
+ const struct h2_proxy_request *req)
{
- h2_ngheader *ngh;
+ h2_proxy_ngheader *ngh;
size_t n;
AP_DEBUG_ASSERT(req);
n = 4;
apr_table_do(count_header, &n, req->headers, NULL);
- ngh = apr_pcalloc(p, sizeof(h2_ngheader));
+ ngh = apr_pcalloc(p, sizeof(h2_proxy_ngheader));
ngh->nv = apr_pcalloc(p, n * sizeof(nghttp2_nv));
NV_ADD_LIT_CS(ngh, ":scheme", req->scheme);
NV_ADD_LIT_CS(ngh, ":authority", req->authority);
return 0;
}
-static int h2_req_ignore_header(const char *name, size_t len)
+static int h2_proxy_req_ignore_header(const char *name, size_t len)
{
return ignore_header(H2_LIT_ARGS(IgnoredRequestHeaders), name, len);
}
int h2_proxy_res_ignore_header(const char *name, size_t len)
{
- return (h2_req_ignore_header(name, len)
+ return (h2_proxy_req_ignore_header(name, len)
|| ignore_header(H2_LIT_ARGS(IgnoredProxyRespHds), name, len));
}
-void h2_util_camel_case_header(char *s, size_t len)
+void h2_proxy_util_camel_case_header(char *s, size_t len)
{
size_t start = 1;
size_t i;
{
char *hname, *hvalue;
- if (h2_req_ignore_header(name, nlen)) {
+ if (h2_proxy_req_ignore_header(name, nlen)) {
return APR_SUCCESS;
}
else if (H2_HD_MATCH_LIT("cookie", name, nlen)) {
hname = apr_pstrndup(pool, name, nlen);
hvalue = apr_pstrndup(pool, value, vlen);
- h2_util_camel_case_header(hname, nlen);
+ h2_proxy_util_camel_case_header(hname, nlen);
apr_table_mergen(headers, hname, hvalue);
return APR_SUCCESS;
}
-static h2_request *h2_req_createn(int id, apr_pool_t *pool, const char *method,
+static h2_proxy_request *h2_proxy_req_createn(int id, apr_pool_t *pool, const char *method,
const char *scheme, const char *authority,
const char *path, apr_table_t *header,
int serialize)
{
- h2_request *req = apr_pcalloc(pool, sizeof(h2_request));
+ h2_proxy_request *req = apr_pcalloc(pool, sizeof(h2_proxy_request));
req->method = method;
req->scheme = scheme;
return req;
}
-h2_request *h2_req_create(int id, apr_pool_t *pool, int serialize)
+h2_proxy_request *h2_proxy_req_create(int id, apr_pool_t *pool, int serialize)
{
- return h2_req_createn(id, pool, NULL, NULL, NULL, NULL, NULL, serialize);
+ return h2_proxy_req_createn(id, pool, NULL, NULL, NULL, NULL, NULL, serialize);
}
typedef struct {
{
h1_ctx *x = ctx;
size_t klen = strlen(key);
- if (!h2_req_ignore_header(key, klen)) {
+ if (!h2_proxy_req_ignore_header(key, klen)) {
h2_headers_add_h1(x->headers, x->pool, key, klen, value, strlen(value));
}
return 1;
}
-apr_status_t h2_req_make(h2_request *req, apr_pool_t *pool,
+apr_status_t h2_proxy_req_make(h2_proxy_request *req, apr_pool_t *pool,
const char *method, const char *scheme,
const char *authority, const char *path,
apr_table_t *headers)
* frame logging
******************************************************************************/
-int h2_util_frame_print(const nghttp2_frame *frame, char *buffer, size_t maxlen)
+int h2_proxy_util_frame_print(const nghttp2_frame *frame, char *buffer, size_t maxlen)
{
char scratch[128];
size_t s_len = sizeof(scratch)/sizeof(scratch[0]);
/*******************************************************************************
* some debugging/format helpers
******************************************************************************/
-struct h2_request;
+struct h2_proxy_request;
struct nghttp2_frame;
-int h2_util_frame_print(const nghttp2_frame *frame, char *buffer, size_t maxlen);
+int h2_proxy_util_frame_print(const nghttp2_frame *frame, char *buffer, size_t maxlen);
/*******************************************************************************
* ihash - hash for structs with int identifier
******************************************************************************/
-typedef struct h2_ihash_t h2_ihash_t;
-typedef int h2_ihash_iter_t(void *ctx, void *val);
+typedef struct h2_proxy_ihash_t h2_proxy_ihash_t;
+typedef int h2_proxy_ihash_iter_t(void *ctx, void *val);
/**
* Create a hash for structures that have an identifying int member.
* @param pool the pool to use
* @param offset_of_int the offsetof() the int member in the struct
*/
-h2_ihash_t *h2_ihash_create(apr_pool_t *pool, size_t offset_of_int);
+h2_proxy_ihash_t *h2_proxy_ihash_create(apr_pool_t *pool, size_t offset_of_int);
-size_t h2_ihash_count(h2_ihash_t *ih);
-int h2_ihash_empty(h2_ihash_t *ih);
-void *h2_ihash_get(h2_ihash_t *ih, int id);
+size_t h2_proxy_ihash_count(h2_proxy_ihash_t *ih);
+int h2_proxy_ihash_empty(h2_proxy_ihash_t *ih);
+void *h2_proxy_ihash_get(h2_proxy_ihash_t *ih, int id);
/**
* Iterate over the hash members (without defined order) and invoke
* @param ctx user supplied data passed into each iteration call
* @return 0 if one iteration returned 0, otherwise != 0
*/
-int h2_ihash_iter(h2_ihash_t *ih, h2_ihash_iter_t *fn, void *ctx);
+int h2_proxy_ihash_iter(h2_proxy_ihash_t *ih, h2_proxy_ihash_iter_t *fn, void *ctx);
-void h2_ihash_add(h2_ihash_t *ih, void *val);
-void h2_ihash_remove(h2_ihash_t *ih, int id);
-void h2_ihash_remove_val(h2_ihash_t *ih, void *val);
-void h2_ihash_clear(h2_ihash_t *ih);
+void h2_proxy_ihash_add(h2_proxy_ihash_t *ih, void *val);
+void h2_proxy_ihash_remove(h2_proxy_ihash_t *ih, int id);
+void h2_proxy_ihash_remove_val(h2_proxy_ihash_t *ih, void *val);
+void h2_proxy_ihash_clear(h2_proxy_ihash_t *ih);
-size_t h2_ihash_shift(h2_ihash_t *ih, void **buffer, size_t max);
-size_t h2_ihash_ishift(h2_ihash_t *ih, int *buffer, size_t max);
+size_t h2_proxy_ihash_shift(h2_proxy_ihash_t *ih, void **buffer, size_t max);
+size_t h2_proxy_ihash_ishift(h2_proxy_ihash_t *ih, int *buffer, size_t max);
/*******************************************************************************
* iqueue - sorted list of int with user defined ordering
******************************************************************************/
-typedef struct h2_iqueue {
+typedef struct h2_proxy_iqueue {
int *elts;
int head;
int nelts;
int nalloc;
apr_pool_t *pool;
-} h2_iqueue;
+} h2_proxy_iqueue;
/**
* Comparator for two int to determine their order.
* < 0: s1 should be sorted before s2
* > 0: s2 should be sorted before s1
*/
-typedef int h2_iq_cmp(int i1, int i2, void *ctx);
+typedef int h2_proxy_iq_cmp(int i1, int i2, void *ctx);
/**
* Allocate a new queue from the pool and initialize.
* @param id the identifier of the queue
* @param pool the memory pool
*/
-h2_iqueue *h2_iq_create(apr_pool_t *pool, int capacity);
+h2_proxy_iqueue *h2_proxy_iq_create(apr_pool_t *pool, int capacity);
/**
* Return != 0 iff there are no tasks in the queue.
* @param q the queue to check
*/
-int h2_iq_empty(h2_iqueue *q);
+int h2_proxy_iq_empty(h2_proxy_iqueue *q);
/**
* Return the number of int in the queue.
* @param q the queue to get size on
*/
-int h2_iq_count(h2_iqueue *q);
+int h2_proxy_iq_count(h2_proxy_iqueue *q);
/**
* Add a stream id to the queue.
* @param cmp the comparator for sorting
* @param ctx user data for comparator
*/
-void h2_iq_add(h2_iqueue *q, int sid, h2_iq_cmp *cmp, void *ctx);
+void h2_proxy_iq_add(h2_proxy_iqueue *q, int sid, h2_proxy_iq_cmp *cmp, void *ctx);
/**
* Remove the stream id from the queue. Return != 0 iff task
* @param sid the stream id to remove
* @return != 0 iff task was found in queue
*/
-int h2_iq_remove(h2_iqueue *q, int sid);
+int h2_proxy_iq_remove(h2_proxy_iqueue *q, int sid);
/**
* Remove all entries in the queue.
*/
-void h2_iq_clear(h2_iqueue *q);
+void h2_proxy_iq_clear(h2_proxy_iqueue *q);
/**
* Sort the stream idqueue again. Call if the task ordering
* @param cmp the comparator for sorting
* @param ctx user data for the comparator
*/
-void h2_iq_sort(h2_iqueue *q, h2_iq_cmp *cmp, void *ctx);
+void h2_proxy_iq_sort(h2_proxy_iqueue *q, h2_proxy_iq_cmp *cmp, void *ctx);
/**
* Get the first stream id from the queue or NULL if the queue is empty.
* @param q the queue to get the first task from
* @return the first stream id of the queue, 0 if empty
*/
-int h2_iq_shift(h2_iqueue *q);
+int h2_proxy_iq_shift(h2_proxy_iqueue *q);
/*******************************************************************************
* common helpers
******************************************************************************/
-/* h2_log2(n) iff n is a power of 2 */
-unsigned char h2_log2(int n);
+/* h2_proxy_log2(n) iff n is a power of 2 */
+unsigned char h2_proxy_log2(int n);
/*******************************************************************************
* HTTP/2 header helpers
******************************************************************************/
-void h2_util_camel_case_header(char *s, size_t len);
+void h2_proxy_util_camel_case_header(char *s, size_t len);
int h2_proxy_res_ignore_header(const char *name, size_t len);
/*******************************************************************************
* nghttp2 helpers
******************************************************************************/
-typedef struct h2_ngheader {
+typedef struct h2_proxy_ngheader {
nghttp2_nv *nv;
apr_size_t nvlen;
-} h2_ngheader;
-h2_ngheader *h2_util_ngheader_make_req(apr_pool_t *p,
- const struct h2_request *req);
+} h2_proxy_ngheader;
+h2_proxy_ngheader *h2_util_ngheader_make_req(apr_pool_t *p,
+ const struct h2_proxy_request *req);
/*******************************************************************************
- * h2_request helpers
+ * h2_proxy_request helpers
******************************************************************************/
-struct h2_request *h2_req_create(int id, apr_pool_t *pool, int serialize);
-apr_status_t h2_req_make(struct h2_request *req, apr_pool_t *pool,
- const char *method, const char *scheme,
- const char *authority, const char *path,
- apr_table_t *headers);
+typedef struct h2_proxy_request h2_proxy_request;
+
+struct h2_proxy_request {
+ const char *method; /* pseudo header values, see ch. 8.1.2.3 */
+ const char *scheme;
+ const char *authority;
+ const char *path;
+
+ apr_table_t *headers;
+
+ apr_time_t request_time;
+
+ unsigned int chunked : 1; /* iff requst body needs to be forwarded as chunked */
+ unsigned int serialize : 1; /* iff this request is written in HTTP/1.1 serialization */
+};
+
+h2_proxy_request *h2_proxy_req_create(int id, apr_pool_t *pool, int serialize);
+apr_status_t h2_proxy_req_make(h2_proxy_request *req, apr_pool_t *pool,
+ const char *method, const char *scheme,
+ const char *authority, const char *path,
+ apr_table_t *headers);
if (ctx->i < end) {
return apr_pstrndup(ctx->pool, ctx->s + ctx->i, end - ctx->i);
}
- return "";
+ return (char*)"";
}
-static int read_qstring(link_ctx *ctx, char **ps)
+static int read_qstring(link_ctx *ctx, const char **ps)
{
if (skip_ws(ctx) && read_chr(ctx, '\"')) {
size_t end;
return 0;
}
-static int read_ptoken(link_ctx *ctx, char **ps)
+static int read_ptoken(link_ctx *ctx, const char **ps)
{
if (skip_ws(ctx)) {
size_t i;
return 0;
}
-static int read_pname(link_ctx *ctx, char **pname)
+static int read_pname(link_ctx *ctx, const char **pname)
{
if (skip_ws(ctx)) {
size_t i;
return 0;
}
-static int read_pvalue(link_ctx *ctx, char **pvalue)
+static int read_pvalue(link_ctx *ctx, const char **pvalue)
{
if (skip_ws(ctx) && read_chr(ctx, '=')) {
if (read_qstring(ctx, pvalue) || read_ptoken(ctx, pvalue)) {
static int read_param(link_ctx *ctx)
{
if (skip_ws(ctx) && read_chr(ctx, ';')) {
- char *name, *value = "";
+ const char *name, *value = "";
if (read_pname(ctx, &name)) {
read_pvalue(ctx, &value); /* value is optional */
apr_table_setn(ctx->params, name, value);
static void calc_apr_hash(h2_push_diary *diary, apr_uint64_t *phash, h2_push *push)
{
apr_uint64_t val;
-#if APR_UINT64MAX > APR_UINT_MAX
- val = (val_apr_hash(push->req->scheme) << 32);
- val ^= (val_apr_hash(push->req->authority) << 16);
+#if APR_UINT64_MAX > UINT_MAX
+ val = ((apr_uint64_t)(val_apr_hash(push->req->scheme)) << 32);
+ val ^= ((apr_uint64_t)(val_apr_hash(push->req->authority)) << 16);
val ^= val_apr_hash(push->req->path);
#else
val = val_apr_hash(push->req->scheme);
}
static h2_push_diary *diary_create(apr_pool_t *p, h2_push_digest_type dtype,
- apr_size_t N)
+ int N)
{
h2_push_diary *diary = NULL;
return diary;
}
-h2_push_diary *h2_push_diary_create(apr_pool_t *p, apr_size_t N)
+h2_push_diary *h2_push_diary_create(apr_pool_t *p, int N)
{
return diary_create(p, H2_PUSH_DIGEST_SHA256, N);
}
int maxP, const char *authority,
const char **pdata, apr_size_t *plen)
{
- apr_size_t nelts, N, i;
+ int nelts, N, i;
unsigned char log2n, log2pmax;
gset_encoder encoder;
apr_uint64_t *hashes;
{
gset_decoder decoder;
unsigned char log2n, log2p;
- apr_size_t N, i;
+ int N, i;
apr_pool_t *pool = diary->entries->pool;
h2_push_diary_entry e;
apr_status_t status = APR_SUCCESS;
* @param N the max number of entries, rounded up to 2^x
* @return the created diary, might be NULL of max_entries is 0
*/
-h2_push_diary *h2_push_diary_create(apr_pool_t *p, apr_size_t N);
+h2_push_diary *h2_push_diary_create(apr_pool_t *p, int N);
/**
* Filters the given pushes against the diary and returns only those pushes
rpath = (req->path ? req->path : "");
ap_parse_uri(r, rpath);
- r->protocol = "HTTP/2.0";
+ r->protocol = (char*)"HTTP/2.0";
r->proto_num = HTTP_VERSION(2, 0);
r->the_request = apr_psprintf(r->pool, "%s %s %s",
nghttp2_priority_spec ps;
int id_parent, id_grandpa, w_parent, w;
int rv = 0;
- char *ptype = "AFTER";
+ const char *ptype = "AFTER";
h2_dependency dep = prio->dependency;
id_parent = nghttp2_stream_get_stream_id(s_parent);
n = nghttp2_session_mem_recv(session->ngh2, (const uint8_t *)data, len);
if (n < 0) {
if (nghttp2_is_fatal((int)n)) {
- dispatch_event(session, H2_SESSION_EV_PROTO_ERROR, (int)n, nghttp2_strerror(n));
+ dispatch_event(session, H2_SESSION_EV_PROTO_ERROR, (int)n, nghttp2_strerror((int)n));
return APR_EGENERAL;
}
}
/*CL*/{ 1, 1, 0, 0, 1, 1, 1 },
};
-static void H2_STREAM_OUT_LOG(int lvl, h2_stream *s, char *tag)
+static void H2_STREAM_OUT_LOG(int lvl, h2_stream *s, const char *tag)
{
if (APLOG_C_IS_LEVEL(s->session->c, lvl)) {
conn_rec *c = s->session->c;
#include "h2_worker.h"
#include "h2_util.h"
-static void H2_TASK_OUT_LOG(int lvl, h2_task *task, apr_bucket_brigade *bb, char *tag)
+static void H2_TASK_OUT_LOG(int lvl, h2_task *task, apr_bucket_brigade *bb,
+ const char *tag)
{
if (APLOG_C_IS_LEVEL(task->c, lvl)) {
conn_rec *c = task->c;
{
apr_bucket *b;
apr_status_t status = APR_SUCCESS;
- int files_allowed = pfile_buckets_allowed? *pfile_buckets_allowed : 0;
+ int files_allowed = pfile_buckets_allowed? (int)*pfile_buckets_allowed : 0;
if (maxlen >= 0) {
/* Find the bucket, up to which we reach maxlen/mem bytes */
* @macro
* Version number of the http2 module as c string
*/
-#define MOD_HTTP2_VERSION "1.7.3"
+#define MOD_HTTP2_VERSION "1.7.4"
/**
* @macro
* 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 0x010703
+#define MOD_HTTP2_VERSION_NUM 0x010704
#endif /* mod_h2_h2_version_h */
return (char *)vdef->lookup(p, s, c, r, ctx);
}
}
- return "";
+ return (char*)"";
}
static int h2_h2_fixups(request_rec *r)
apr_pool_t *engine_pool;
apr_size_t req_buffer_size;
request_rec *next;
- apr_size_t capacity;
+ int capacity;
unsigned standalone : 1;
unsigned is_ssl : 1;
path = url; /* this is the raw path */
}
else {
- path = ap_proxy_canonenc(r->pool, url, strlen(url),
+ path = ap_proxy_canonenc(r->pool, url, (int)strlen(url),
enc_path, 0, r->proxyreq);
search = r->args;
}
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, ctx->owner,
"eng(%s): setup session", ctx->engine_id);
ctx->session = h2_proxy_session_setup(ctx->engine_id, ctx->p_conn, ctx->conf,
- 30, h2_log2(ctx->req_buffer_size),
+ 30, h2_proxy_log2(ctx->req_buffer_size),
request_done);
if (!ctx->session) {
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, ctx->owner,
/* ongoing processing, call again */
if (ctx->session->remote_max_concurrent > 0
&& ctx->session->remote_max_concurrent != ctx->capacity) {
- ctx->capacity = ctx->session->remote_max_concurrent;
+ ctx->capacity = (int)ctx->session->remote_max_concurrent;
}
s2 = next_request(ctx, 0);
if (s2 == APR_ECONNABORTED) {
status = s2;
break;
}
- if (!ctx->next && h2_ihash_empty(ctx->session->streams)) {
+ if (!ctx->next && h2_proxy_ihash_empty(ctx->session->streams)) {
break;
}
}