From: Jean-Frederic Clere Date: Fri, 17 Jul 2015 15:46:19 +0000 (+0000) Subject: Arrange the C++ declarations to make my compiler happy. X-Git-Tag: 2.5.0-alpha~2999 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=867e69cc244d10c63013a3b84022a27f8df13d99;p=apache Arrange the C++ declarations to make my compiler happy. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1691592 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http2/h2_alpn.c b/modules/http2/h2_alpn.c index 1b3e28614b..6a76f7fbda 100644 --- a/modules/http2/h2_alpn.c +++ b/modules/http2/h2_alpn.c @@ -257,11 +257,11 @@ static int h2_alpn_negotiated(conn_rec *c, int h2_alpn_pre_conn(conn_rec* c, void *arg) { - (void)arg; + h2_ctx *ctx = h2_ctx_get(c); + ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, c, "h2_h2, pre_connection, start"); - h2_ctx *ctx = h2_ctx_get(c); if (h2_ctx_is_task(ctx)) { /* our stream pseudo connection */ return DECLINED; diff --git a/modules/http2/h2_alt_svc.c b/modules/http2/h2_alt_svc.c index 37f7692d29..b80bc54ee5 100644 --- a/modules/http2/h2_alt_svc.c +++ b/modules/http2/h2_alt_svc.c @@ -72,12 +72,13 @@ h2_alt_svc *h2_alt_svc_parse(const char *s, apr_pool_t *pool) { static int h2_alt_svc_request_handler(request_rec *r) { h2_ctx *ctx = h2_ctx_rget(r); + h2_config *cfg; if (h2_ctx_is_active(ctx) || h2_ctx_is_task(ctx)) { return DECLINED; } - h2_config *cfg = h2_config_rget(r); + cfg = h2_config_rget(r); if (r->hostname && cfg && cfg->alt_svcs && cfg->alt_svcs->nelts > 0) { const char *alt_svc_used = apr_table_get(r->headers_in, "Alt-Svc-Used"); if (!alt_svc_used /*|| (alt_svc_used[0] == '0')*/) { diff --git a/modules/http2/h2_config.c b/modules/http2/h2_config.c index 62c96634e4..08e19ea404 100644 --- a/modules/http2/h2_config.c +++ b/modules/http2/h2_config.c @@ -485,6 +485,7 @@ h2_config *h2_config_get(conn_rec *c) * the vhost matching stuff. */ apr_uri_t uri; + request_rec r; memset(&uri, 0, sizeof(uri)); uri.scheme = (char*)"https"; uri.hostinfo = (char*)ctx->hostname; @@ -493,7 +494,6 @@ h2_config *h2_config_get(conn_rec *c) uri.port = c->local_addr->port; uri.path = (char*)"/"; - request_rec r; memset(&r, 0, sizeof(r)); r.uri = (char*)"/"; r.connection = c; diff --git a/modules/http2/h2_conn.c b/modules/http2/h2_conn.c index 407b4eacfd..fc75704e9e 100644 --- a/modules/http2/h2_conn.c +++ b/modules/http2/h2_conn.c @@ -79,8 +79,10 @@ apr_status_t h2_conn_child_init(apr_pool_t *pool, server_rec *s) int maxw = h2_config_geti(config, H2_CONF_MAX_WORKERS); int max_threads_per_child = 0; - ap_mpm_query(AP_MPMQ_MAX_THREADS, &max_threads_per_child); int threads_limit = 0; + int idle_secs = 0; + + ap_mpm_query(AP_MPMQ_MAX_THREADS, &max_threads_per_child); ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &threads_limit); if (minw <= 0) { @@ -117,7 +119,7 @@ apr_status_t h2_conn_child_init(apr_pool_t *pool, server_rec *s) minw, maxw, max_threads_per_child, threads_limit); workers = h2_workers_create(s, pool, minw, maxw); - int idle_secs = h2_config_geti(config, H2_CONF_MAX_WORKER_IDLE_SECS); + idle_secs = h2_config_geti(config, H2_CONF_MAX_WORKER_IDLE_SECS); h2_workers_set_max_idle_secs(workers, idle_secs); return status; @@ -136,6 +138,7 @@ module *h2_conn_mpm_module(void) { apr_status_t h2_conn_rprocess(request_rec *r) { h2_config *config = h2_config_rget(r); + h2_session *session; ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "h2_conn_process start"); if (!workers) { @@ -143,7 +146,7 @@ apr_status_t h2_conn_rprocess(request_rec *r) return APR_EGENERAL; } - h2_session *session = h2_session_rcreate(r, config, workers); + session = h2_session_rcreate(r, config, workers); if (!session) { return APR_EGENERAL; } @@ -154,6 +157,7 @@ apr_status_t h2_conn_rprocess(request_rec *r) apr_status_t h2_conn_main(conn_rec *c) { h2_config *config = h2_config_get(c); + h2_session *session; ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c, "h2_conn_main start"); if (!workers) { @@ -161,7 +165,7 @@ apr_status_t h2_conn_main(conn_rec *c) return APR_EGENERAL; } - h2_session *session = h2_session_create(c, config, workers); + session = h2_session_create(c, config, workers); if (!session) { return APR_EGENERAL; } @@ -173,6 +177,8 @@ apr_status_t h2_session_process(h2_session *session) { apr_status_t status = APR_SUCCESS; int rv = 0; + apr_interval_time_t wait_micros = 0; + static const int MAX_WAIT_MICROS = 200 * 1000; /* Start talking to the client. Apart from protocol meta data, * we mainly will see new http/2 streams opened by the client, which @@ -224,12 +230,10 @@ apr_status_t h2_session_process(h2_session *session) return status; } - apr_interval_time_t wait_micros = 0; - static const int MAX_WAIT_MICROS = 200 * 1000; - while (!h2_session_is_done(session)) { int have_written = 0; int have_read = 0; + int got_streams; status = h2_session_write(session, wait_micros); if (status == APR_SUCCESS) { @@ -263,7 +267,7 @@ apr_status_t h2_session_process(h2_session *session) * * h2c will count the header settings as one frame and we * submit our settings and need the ACK. */ - int got_streams = !h2_stream_set_is_empty(session->streams); + got_streams = !h2_stream_set_is_empty(session->streams); status = h2_session_read(session, (!got_streams || session->frames_received <= 1)? @@ -323,6 +327,7 @@ static void fix_event_conn(conn_rec *c, conn_rec *master); conn_rec *h2_conn_create(conn_rec *master, apr_pool_t *pool) { apr_socket_t *socket; + conn_rec *c; AP_DEBUG_ASSERT(master); @@ -340,7 +345,7 @@ conn_rec *h2_conn_create(conn_rec *master, apr_pool_t *pool) * TODO */ socket = ap_get_module_config(master->conn_config, &core_module); - conn_rec *c = ap_run_create_connection(pool, master->base_server, + c = ap_run_create_connection(pool, master->base_server, socket, master->id^((long)pool), master->sbh, diff --git a/modules/http2/h2_conn_io.c b/modules/http2/h2_conn_io.c index 8cf2058f28..55e48119aa 100644 --- a/modules/http2/h2_conn_io.c +++ b/modules/http2/h2_conn_io.c @@ -174,10 +174,11 @@ apr_status_t h2_conn_io_read(h2_conn_io *io, static apr_status_t flush_out(apr_bucket_brigade *bb, void *ctx) { h2_conn_io *io = (h2_conn_io*)ctx; + apr_status_t status; ap_update_child_status(io->connection->sbh, SERVER_BUSY_WRITE, NULL); - apr_status_t status = ap_pass_brigade(io->connection->output_filters, bb); + status = ap_pass_brigade(io->connection->output_filters, bb); apr_brigade_cleanup(bb); return status; } @@ -257,10 +258,12 @@ apr_status_t h2_conn_io_write(h2_conn_io *io, apr_status_t h2_conn_io_flush(h2_conn_io *io) { if (io->unflushed) { + apr_status_t status; if (io->buflen > 0) { + apr_bucket *b; ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, io->connection, "h2_conn_io: flush, flushing %ld bytes", (long)io->buflen); - apr_bucket *b = apr_bucket_transient_create(io->buffer, io->buflen, + b = apr_bucket_transient_create(io->buffer, io->buflen, io->output->bucket_alloc); APR_BRIGADE_INSERT_TAIL(io->output, b); io->buflen = 0; @@ -271,7 +274,7 @@ apr_status_t h2_conn_io_flush(h2_conn_io *io) apr_bucket_flush_create(io->output->bucket_alloc)); /* Send it out through installed filters (TLS) to the client */ - apr_status_t status = flush_out(io->output, io); + status = flush_out(io->output, io); if (status == APR_SUCCESS || APR_STATUS_IS_ECONNABORTED(status) diff --git a/modules/http2/h2_from_h1.c b/modules/http2/h2_from_h1.c index eac4e7e8d2..0d39248ad8 100644 --- a/modules/http2/h2_from_h1.c +++ b/modules/http2/h2_from_h1.c @@ -107,12 +107,13 @@ static apr_status_t parse_header(h2_from_h1 *from_h1, ap_filter_t* f, (void)f; if (line[0] == ' ' || line[0] == '\t') { + char **plast; /* continuation line from the header before this */ while (line[0] == ' ' || line[0] == '\t') { ++line; } - char **plast = apr_array_pop(from_h1->hlines); + plast = apr_array_pop(from_h1->hlines); if (plast == NULL) { /* not well formed */ return APR_EINVAL; @@ -129,13 +130,14 @@ static apr_status_t parse_header(h2_from_h1 *from_h1, ap_filter_t* f, static apr_status_t get_line(h2_from_h1 *from_h1, apr_bucket_brigade *bb, ap_filter_t* f, char *line, apr_size_t len) { + apr_status_t status; if (!from_h1->bb) { from_h1->bb = apr_brigade_create(from_h1->pool, f->c->bucket_alloc); } else { apr_brigade_cleanup(from_h1->bb); } - apr_status_t status = apr_brigade_split_line(from_h1->bb, bb, + status = apr_brigade_split_line(from_h1->bb, bb, APR_BLOCK_READ, HUGE_STRING_LEN); if (status == APR_SUCCESS) { @@ -444,6 +446,7 @@ static h2_response *create_response(h2_from_h1 *from_h1, request_rec *r) apr_status_t status = APR_SUCCESS; const char *clheader; const char *ctype; + apr_table_t *headers; /* * Now that we are ready to send a response, we need to combine the two * header field tables into a single table. If we don't do this, our @@ -541,7 +544,7 @@ static h2_response *create_response(h2_from_h1 *from_h1, request_rec *r) apr_table_unset(r->headers_out, "Content-Length"); } - apr_table_t *headers = apr_table_make(r->pool, 10); + headers = apr_table_make(r->pool, 10); set_basic_http_header(r, headers); if (r->status == HTTP_NOT_MODIFIED) { diff --git a/modules/http2/h2_io.c b/modules/http2/h2_io.c index aa0619e230..c4039194eb 100644 --- a/modules/http2/h2_io.c +++ b/modules/http2/h2_io.c @@ -73,14 +73,16 @@ apr_status_t h2_io_in_read(h2_io *io, apr_bucket_brigade *bb, apr_size_t maxlen) { apr_off_t start_len = 0; + apr_bucket *last; + apr_status_t status; if (!io->bbin || APR_BRIGADE_EMPTY(io->bbin)) { return io->eos_in? APR_EOF : APR_EAGAIN; } apr_brigade_length(bb, 1, &start_len); - apr_bucket *last = APR_BRIGADE_LAST(bb); - apr_status_t status = h2_util_move(bb, io->bbin, maxlen, 0, + last = APR_BRIGADE_LAST(bb); + status = h2_util_move(bb, io->bbin, maxlen, 0, "h2_io_in_read"); if (status == APR_SUCCESS) { apr_bucket *nlast = APR_BRIGADE_LAST(bb); diff --git a/modules/http2/h2_io_set.c b/modules/http2/h2_io_set.c index 40a7ef351e..c80ede4acb 100644 --- a/modules/http2/h2_io_set.c +++ b/modules/http2/h2_io_set.c @@ -95,13 +95,14 @@ apr_status_t h2_io_set_add(h2_io_set *sp, h2_io *io) { h2_io *existing = h2_io_set_get(sp, io->id); if (!existing) { + int last; APR_ARRAY_PUSH(sp->list, h2_io*) = io; /* Normally, streams get added in ascending order if id. We * keep the array sorted, so we just need to check of the newly * appended stream has a lower id than the last one. if not, * sorting is not necessary. */ - int last = sp->list->nelts - 1; + last = sp->list->nelts - 1; if (last > 0 && (h2_io_IDX(sp->list, last)->id < h2_io_IDX(sp->list, last-1)->id)) { @@ -116,8 +117,9 @@ h2_io *h2_io_set_remove(h2_io_set *sp, h2_io *io) for (int i = 0; i < sp->list->nelts; ++i) { h2_io *e = h2_io_IDX(sp->list, i); if (e == io) { + int n; --sp->list->nelts; - int n = sp->list->nelts - i; + n = sp->list->nelts - i; if (n > 0) { /* Close the hole in the array by moving the upper * parts down one step. diff --git a/modules/http2/h2_mplx.c b/modules/http2/h2_mplx.c index 64d2e9bbab..dce33b59ea 100644 --- a/modules/http2/h2_mplx.c +++ b/modules/http2/h2_mplx.c @@ -96,15 +96,16 @@ h2_mplx *h2_mplx_create(conn_rec *c, apr_pool_t *parent, h2_workers *workers) { apr_status_t status = APR_SUCCESS; h2_config *conf = h2_config_get(c); + apr_allocator_t *allocator = NULL; + h2_mplx *m; AP_DEBUG_ASSERT(conf); - apr_allocator_t *allocator = NULL; status = apr_allocator_create(&allocator); if (status != APR_SUCCESS) { return NULL; } - h2_mplx *m = apr_pcalloc(parent, sizeof(h2_mplx)); + m = apr_pcalloc(parent, sizeof(h2_mplx)); if (m) { m->id = c->id; APR_RING_ELEM_INIT(m, link); @@ -181,9 +182,10 @@ static void workers_unregister(h2_mplx *m) { apr_status_t h2_mplx_release_and_join(h2_mplx *m, apr_thread_cond_t *wait) { + apr_status_t status; workers_unregister(m); - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { int attempts = 0; @@ -215,8 +217,9 @@ apr_status_t h2_mplx_release_and_join(h2_mplx *m, apr_thread_cond_t *wait) void h2_mplx_abort(h2_mplx *m) { + apr_status_t status; AP_DEBUG_ASSERT(m); - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { m->aborted = 1; h2_io_set_destroy_all(m->stream_ios); @@ -229,11 +232,13 @@ void h2_mplx_abort(h2_mplx *m) h2_stream *h2_mplx_open_io(h2_mplx *m, int stream_id) { h2_stream *stream = NULL; + apr_status_t status; + h2_io *io; if (m->aborted) { return NULL; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { apr_pool_t *stream_pool = m->spare_pool; @@ -247,7 +252,7 @@ h2_stream *h2_mplx_open_io(h2_mplx *m, int stream_id) stream = h2_stream_create(stream_id, stream_pool, m); stream->state = H2_STREAM_ST_OPEN; - h2_io *io = h2_io_set_get(m->stream_ios, stream_id); + io = h2_io_set_get(m->stream_ios, stream_id); if (!io) { io = h2_io_create(stream_id, stream_pool, m->bucket_alloc); h2_io_set_add(m->stream_ios, io); @@ -281,8 +286,9 @@ static void stream_destroy(h2_mplx *m, h2_stream *stream, h2_io *io) apr_status_t h2_mplx_cleanup_stream(h2_mplx *m, h2_stream *stream) { + apr_status_t status; AP_DEBUG_ASSERT(m); - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { h2_io *io = h2_io_set_get(m->stream_ios, stream->id); if (!io || io->task_done) { @@ -326,11 +332,12 @@ apr_status_t h2_mplx_in_read(h2_mplx *m, apr_read_type_e block, int stream_id, apr_bucket_brigade *bb, struct apr_thread_cond_t *iowait) { + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return APR_ECONNABORTED; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { h2_io *io = h2_io_set_get(m->stream_ios, stream_id); if (io) { @@ -355,11 +362,12 @@ apr_status_t h2_mplx_in_read(h2_mplx *m, apr_read_type_e block, apr_status_t h2_mplx_in_write(h2_mplx *m, int stream_id, apr_bucket_brigade *bb) { + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return APR_ECONNABORTED; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { h2_io *io = h2_io_set_get(m->stream_ios, stream_id); if (io) { @@ -378,11 +386,12 @@ apr_status_t h2_mplx_in_write(h2_mplx *m, int stream_id, apr_status_t h2_mplx_in_close(h2_mplx *m, int stream_id) { + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return APR_ECONNABORTED; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { h2_io *io = h2_io_set_get(m->stream_ios, stream_id); if (io) { @@ -419,11 +428,12 @@ static int update_window(void *ctx, h2_io *io) apr_status_t h2_mplx_in_update_windows(h2_mplx *m, h2_mplx_consumed_cb *cb, void *cb_ctx) { + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return APR_ECONNABORTED; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { update_ctx ctx = { cb, cb_ctx, 0 }; status = APR_EAGAIN; @@ -441,11 +451,12 @@ apr_status_t h2_mplx_out_readx(h2_mplx *m, int stream_id, h2_io_data_cb *cb, void *ctx, apr_size_t *plen, int *peos) { + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return APR_ECONNABORTED; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { h2_io *io = h2_io_set_get(m->stream_ios, stream_id); if (io) { @@ -464,12 +475,13 @@ apr_status_t h2_mplx_out_readx(h2_mplx *m, int stream_id, h2_stream *h2_mplx_next_submit(h2_mplx *m, h2_stream_set *streams) { + apr_status_t status; + h2_stream *stream = NULL; AP_DEBUG_ASSERT(m); if (m->aborted) { return NULL; } - h2_stream *stream = NULL; - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { h2_io *io = h2_io_set_get_highest_prio(m->ready_ios); if (io) { @@ -562,11 +574,12 @@ apr_status_t h2_mplx_out_open(h2_mplx *m, int stream_id, h2_response *response, ap_filter_t* f, apr_bucket_brigade *bb, struct apr_thread_cond_t *iowait) { + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return APR_ECONNABORTED; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { status = out_open(m, stream_id, response, f, bb, iowait); if (m->aborted) { @@ -582,11 +595,12 @@ apr_status_t h2_mplx_out_write(h2_mplx *m, int stream_id, ap_filter_t* f, apr_bucket_brigade *bb, struct apr_thread_cond_t *iowait) { + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return APR_ECONNABORTED; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { if (!m->aborted) { h2_io *io = h2_io_set_get(m->stream_ios, stream_id); @@ -611,11 +625,12 @@ apr_status_t h2_mplx_out_write(h2_mplx *m, int stream_id, apr_status_t h2_mplx_out_close(h2_mplx *m, int stream_id) { + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return APR_ECONNABORTED; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { if (!m->aborted) { h2_io *io = h2_io_set_get(m->stream_ios, stream_id); @@ -649,12 +664,13 @@ apr_status_t h2_mplx_out_close(h2_mplx *m, int stream_id) int h2_mplx_in_has_eos_for(h2_mplx *m, int stream_id) { + int has_eos = 0; + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return 0; } - int has_eos = 0; - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { h2_io *io = h2_io_set_get(m->stream_ios, stream_id); if (io) { @@ -667,12 +683,13 @@ int h2_mplx_in_has_eos_for(h2_mplx *m, int stream_id) int h2_mplx_out_has_data_for(h2_mplx *m, int stream_id) { + apr_status_t status; + int has_data = 0; AP_DEBUG_ASSERT(m); if (m->aborted) { return 0; } - int has_data = 0; - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { h2_io *io = h2_io_set_get(m->stream_ios, stream_id); if (io) { @@ -686,11 +703,12 @@ int h2_mplx_out_has_data_for(h2_mplx *m, int stream_id) apr_status_t h2_mplx_out_trywait(h2_mplx *m, apr_interval_time_t timeout, apr_thread_cond_t *iowait) { + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return APR_ECONNABORTED; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { m->added_output = iowait; status = apr_thread_cond_timedwait(m->added_output, m->lock, timeout); @@ -716,11 +734,12 @@ static void have_out_data_for(h2_mplx *m, int stream_id) apr_status_t h2_mplx_do_task(h2_mplx *m, struct h2_task *task) { + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return APR_ECONNABORTED; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { /* TODO: needs to sort queue by priority */ ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, m->c, @@ -735,12 +754,13 @@ apr_status_t h2_mplx_do_task(h2_mplx *m, struct h2_task *task) h2_task *h2_mplx_pop_task(h2_mplx *m, int *has_more) { h2_task *task = NULL; + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { *has_more = 0; return NULL; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { task = h2_tq_pop_first(m->q); if (task) { @@ -754,11 +774,12 @@ h2_task *h2_mplx_pop_task(h2_mplx *m, int *has_more) apr_status_t h2_mplx_create_task(h2_mplx *m, struct h2_stream *stream) { + apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return APR_ECONNABORTED; } - apr_status_t status = apr_thread_mutex_lock(m->lock); + status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { conn_rec *c = h2_conn_create(m->c, stream->pool); diff --git a/modules/http2/h2_request.c b/modules/http2/h2_request.c index 62744c09cf..41e64b4ae8 100644 --- a/modules/http2/h2_request.c +++ b/modules/http2/h2_request.c @@ -54,6 +54,7 @@ static apr_status_t insert_request_line(h2_request *req, h2_mplx *m); apr_status_t h2_request_rwrite(h2_request *req, request_rec *r, h2_mplx *m) { + apr_status_t status; req->method = r->method; req->path = r->uri; req->authority = r->hostname; @@ -64,7 +65,7 @@ apr_status_t h2_request_rwrite(h2_request *req, request_rec *r, h2_mplx *m) req->scheme = NULL; - apr_status_t status = insert_request_line(req, m); + status = insert_request_line(req, m); if (status == APR_SUCCESS) { status = h2_to_h1_add_headers(req->to_h1, r->headers_in); } diff --git a/modules/http2/h2_response.c b/modules/http2/h2_response.c index 837b03fc74..fc2107cc39 100644 --- a/modules/http2/h2_response.c +++ b/modules/http2/h2_response.c @@ -210,14 +210,17 @@ static int add_header(void *ctx, const char *key, const char *value) static void convert_header(h2_response *response, apr_table_t *headers, const char *status, request_rec *r) { + size_t n; + h2_headers *h; nvctx_t ctx = { NULL, 1, strlen(status) + 1, 0, NULL, response, r? APLOGrdebug(r) : 0, r }; apr_table_do(count_headers, &ctx, headers, NULL); - size_t n = (sizeof(h2_headers) + n = (sizeof(h2_headers) + (ctx.nvlen * sizeof(nghttp2_nv)) + ctx.nvstrlen); - h2_headers *h = calloc(1, n); + /* XXX: Why calloc, Why not on the pool of the request? */ + h = calloc(1, n); if (h) { ctx.nv = (nghttp2_nv*)(h + 1); ctx.strbuf = (char*)&ctx.nv[ctx.nvlen]; diff --git a/modules/http2/h2_session.c b/modules/http2/h2_session.c index cb70dd1604..4a24973055 100644 --- a/modules/http2/h2_session.c +++ b/modules/http2/h2_session.c @@ -56,11 +56,12 @@ static int h2_session_status_from_apr_status(apr_status_t rv) static int stream_open(h2_session *session, int stream_id) { + h2_stream * stream; if (session->aborted) { return NGHTTP2_ERR_CALLBACK_FAILURE; } - h2_stream * stream = h2_mplx_open_io(session->mplx, stream_id); + stream = h2_mplx_open_io(session->mplx, stream_id); if (stream) { h2_stream_set_add(session->streams, stream); @@ -96,7 +97,6 @@ static ssize_t send_cb(nghttp2_session *ngh2, { h2_session *session = (h2_session *)userp; apr_status_t status = send_data(session, (const char *)data, length); - (void)ngh2; (void)flags; if (status == APR_SUCCESS) { return length; @@ -136,12 +136,13 @@ static int on_data_chunk_recv_cb(nghttp2_session *ngh2, uint8_t flags, { int rv; h2_session *session = (h2_session *)userp; - (void)flags; + h2_stream * stream; + apr_status_t status; if (session->aborted) { return NGHTTP2_ERR_CALLBACK_FAILURE; } - h2_stream * stream = h2_stream_set_get(session->streams, stream_id); + stream = h2_stream_set_get(session->streams, stream_id); if (!stream) { ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, session->c, "h2_session: stream(%ld-%d): on_data_chunk for unknown stream", @@ -154,7 +155,7 @@ static int on_data_chunk_recv_cb(nghttp2_session *ngh2, uint8_t flags, return 0; } - apr_status_t status = h2_stream_write_data(stream, (const char *)data, len); + status = h2_stream_write_data(stream, (const char *)data, len); ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c, "h2_stream(%ld-%d): written DATA, length %d", session->id, stream_id, (int)len); @@ -229,12 +230,12 @@ static int on_stream_close_cb(nghttp2_session *ngh2, int32_t stream_id, uint32_t error_code, void *userp) { h2_session *session = (h2_session *)userp; - (void)ngh2; + h2_stream *stream; if (session->aborted) { return NGHTTP2_ERR_CALLBACK_FAILURE; } - h2_stream *stream = h2_stream_set_get(session->streams, stream_id); + stream = h2_stream_set_get(session->streams, stream_id); if (stream) { stream_destroy(session, stream); } @@ -251,7 +252,6 @@ static int on_stream_close_cb(nghttp2_session *ngh2, int32_t stream_id, static int on_begin_headers_cb(nghttp2_session *ngh2, const nghttp2_frame *frame, void *userp) { - (void)ngh2; /* This starts a new stream. */ int rv = stream_open((h2_session *)userp, frame->hd.stream_id); if (rv != NGHTTP2_ERR_CALLBACK_FAILURE) { @@ -269,12 +269,13 @@ static int on_header_cb(nghttp2_session *ngh2, const nghttp2_frame *frame, void *userp) { h2_session *session = (h2_session *)userp; - (void)ngh2; (void)flags; + h2_stream * stream; + apr_status_t status; if (session->aborted) { return NGHTTP2_ERR_CALLBACK_FAILURE; } - h2_stream * stream = h2_stream_set_get(session->streams, + stream = h2_stream_set_get(session->streams, frame->hd.stream_id); if (!stream) { ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, session->c, @@ -283,7 +284,7 @@ static int on_header_cb(nghttp2_session *ngh2, const nghttp2_frame *frame, return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; } - apr_status_t status = h2_stream_write_header(stream, + status = h2_stream_write_header(stream, (const char *)name, namelen, (const char *)value, valuelen); if (status != APR_SUCCESS) { @@ -303,10 +304,10 @@ static int on_frame_recv_cb(nghttp2_session *ng2s, { int rv; h2_session *session = (h2_session *)userp; + apr_status_t status = APR_SUCCESS; if (session->aborted) { return NGHTTP2_ERR_CALLBACK_FAILURE; } - apr_status_t status = APR_SUCCESS; ++session->frames_received; ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c, @@ -314,6 +315,7 @@ static int on_frame_recv_cb(nghttp2_session *ng2s, (long)session->frames_received, frame->hd.type); switch (frame->hd.type) { case NGHTTP2_HEADERS: { + int eos; h2_stream * stream = h2_stream_set_get(session->streams, frame->hd.stream_id); if (stream == NULL) { @@ -330,7 +332,7 @@ static int on_frame_recv_cb(nghttp2_session *ng2s, return 0; } - int eos = (frame->hd.flags & NGHTTP2_FLAG_END_STREAM); + eos = (frame->hd.flags & NGHTTP2_FLAG_END_STREAM); status = stream_end_headers(session, stream, eos); break; @@ -522,12 +524,14 @@ static h2_session *h2_session_create_int(conn_rec *c, apr_pool_t *pool = NULL; apr_status_t status = apr_pool_create(&pool, r? r->pool : c->pool); + h2_session *session; if (status != APR_SUCCESS) { return NULL; } - h2_session *session = apr_pcalloc(pool, sizeof(h2_session)); + session = apr_pcalloc(pool, sizeof(h2_session)); if (session) { + int rv; session->id = c->id; session->c = c; session->r = r; @@ -558,7 +562,7 @@ static h2_session *h2_session_create_int(conn_rec *c, return NULL; } - int rv = nghttp2_option_new(&options); + rv = nghttp2_option_new(&options); if (rv != 0) { ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, c, "nghttp2_option_new: %s", nghttp2_strerror(rv)); @@ -636,13 +640,14 @@ void h2_session_destroy(h2_session *session) apr_status_t h2_session_goaway(h2_session *session, apr_status_t reason) { - AP_DEBUG_ASSERT(session); apr_status_t status = APR_SUCCESS; + int rv; + AP_DEBUG_ASSERT(session); if (session->aborted) { return APR_EINVAL; } - int rv = 0; + rv = 0; if (reason == APR_SUCCESS) { rv = nghttp2_submit_shutdown_notice(session->ngh2); } @@ -708,25 +713,31 @@ apr_status_t h2_session_abort(h2_session *session, apr_status_t reason, int rv) apr_status_t h2_session_start(h2_session *session, int *rv) { + apr_status_t status = APR_SUCCESS; + h2_config *config; + nghttp2_settings_entry settings[3]; AP_DEBUG_ASSERT(session); /* Start the conversation by submitting our SETTINGS frame */ - apr_status_t status = APR_SUCCESS; *rv = 0; - h2_config *config = h2_config_get(session->c); + config = h2_config_get(session->c); if (session->r) { + const char *s, *cs; + apr_size_t dlen; + h2_stream * stream; + /* better for vhost matching */ config = h2_config_rget(session->r); /* 'h2c' mode: we should have a 'HTTP2-Settings' header with * base64 encoded client settings. */ - const char *s = apr_table_get(session->r->headers_in, "HTTP2-Settings"); + s = apr_table_get(session->r->headers_in, "HTTP2-Settings"); if (!s) { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EINVAL, session->r, "HTTP2-Settings header missing in request"); return APR_EINVAL; } - unsigned char *cs = NULL; - apr_size_t dlen = h2_util_base64url_decode(&cs, s, session->pool); + cs = NULL; + dlen = h2_util_base64url_decode(&cs, s, session->pool); if (APLOGrdebug(session->r)) { char buffer[128]; @@ -753,7 +764,7 @@ apr_status_t h2_session_start(h2_session *session, int *rv) return status; } - h2_stream * stream = h2_stream_set_get(session->streams, 1); + stream = h2_stream_set_get(session->streams, 1); if (stream == NULL) { status = APR_EGENERAL; ap_log_rerror(APLOG_MARK, APLOG_ERR, status, session->r, @@ -771,14 +782,13 @@ apr_status_t h2_session_start(h2_session *session, int *rv) } } - nghttp2_settings_entry settings[] = { - { NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE, - h2_config_geti(config, H2_CONF_MAX_HL_SIZE) }, - { NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, - h2_config_geti(config, H2_CONF_WIN_SIZE) }, - {NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, - (uint32_t)session->max_stream_count }, - }; + settings[0].settings_id = NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE; + settings[0].value = h2_config_geti(config, H2_CONF_MAX_HL_SIZE); + settings[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; + settings[1].value = h2_config_geti(config, H2_CONF_WIN_SIZE); + settings[2].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; + settings[2].value = (uint32_t)session->max_stream_count; + *rv = nghttp2_submit_settings(session->ngh2, NGHTTP2_FLAG_NONE, settings, sizeof(settings)/sizeof(settings[0])); @@ -809,10 +819,11 @@ static int resume_on_data(void *ctx, h2_stream *stream) { if (h2_stream_is_suspended(stream)) { if (h2_mplx_out_has_data_for(stream->m, stream->id)) { + int rv; h2_stream_set_suspended(stream, 0); ++rctx->resume_count; - int rv = nghttp2_session_resume_data(session->ngh2, stream->id); + rv = nghttp2_session_resume_data(session->ngh2, stream->id); ap_log_cerror(APLOG_MARK, nghttp2_is_fatal(rv)? APLOG_ERR : APLOG_DEBUG, 0, session->c, "h2_stream(%ld-%d): resuming stream %s", @@ -864,8 +875,9 @@ apr_status_t h2_session_write(h2_session *session, apr_interval_time_t timeout) } if (h2_session_want_write(session)) { + int rv; status = APR_SUCCESS; - int rv = nghttp2_session_send(session->ngh2); + rv = nghttp2_session_send(session->ngh2); if (rv != 0) { ap_log_cerror( APLOG_MARK, APLOG_DEBUG, 0, session->c, "h2_session: send: %s", nghttp2_strerror(rv)); @@ -901,8 +913,9 @@ apr_status_t h2_session_write(h2_session *session, apr_interval_time_t timeout) } if (h2_session_want_write(session)) { + int rv; status = APR_SUCCESS; - int rv = nghttp2_session_send(session->ngh2); + rv = nghttp2_session_send(session->ngh2); if (rv != 0) { ap_log_cerror( APLOG_MARK, APLOG_DEBUG, 0, session->c, "h2_session: send2: %s", nghttp2_strerror(rv)); @@ -980,10 +993,13 @@ static ssize_t stream_data_cb(nghttp2_session *ng2s, void *puser) { h2_session *session = (h2_session *)puser; + apr_size_t nread = length; + int eos = 0; + apr_status_t status; + h2_stream *stream; AP_DEBUG_ASSERT(session); - (void)ng2s;(void)source;(void)buf; - h2_stream *stream = h2_stream_set_get(session->streams, stream_id); + stream = h2_stream_set_get(session->streams, stream_id); if (!stream) { ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_NOTFOUND, session->c, "h2_stream(%ld-%d): data requested but stream not found", @@ -992,10 +1008,8 @@ static ssize_t stream_data_cb(nghttp2_session *ng2s, } AP_DEBUG_ASSERT(!h2_stream_is_suspended(stream)); - apr_size_t nread = length; - int eos = 0; - apr_status_t status = h2_stream_prep_read(stream, &nread, &eos); + status = h2_stream_prep_read(stream, &nread, &eos); if (nread) { *data_flags |= NGHTTP2_DATA_FLAG_NO_COPY; } @@ -1044,6 +1058,7 @@ typedef struct { static int submit_response(h2_session *session, h2_response *response) { + int rv; nghttp2_data_provider provider = { (nghttp2_data_source) response->stream_id, (nghttp2_data_source_read_callback) stream_data_cb @@ -1053,7 +1068,7 @@ static int submit_response(h2_session *session, h2_response *response) "h2_stream(%ld-%d): submitting response %s", session->id, response->stream_id, response->headers->status); - int rv = nghttp2_submit_response(session->ngh2, response->stream_id, + rv = nghttp2_submit_response(session->ngh2, response->stream_id, response->headers->nv, response->headers->nvlen, &provider); @@ -1077,12 +1092,12 @@ static int submit_response(h2_session *session, h2_response *response) */ apr_status_t h2_session_handle_response(h2_session *session, h2_stream *stream) { + apr_status_t status = APR_SUCCESS; + int rv = 0; AP_DEBUG_ASSERT(session); AP_DEBUG_ASSERT(stream); AP_DEBUG_ASSERT(stream->response); - apr_status_t status = APR_SUCCESS; - int rv = 0; if (stream->response->headers) { rv = submit_response(session, stream->response); } diff --git a/modules/http2/h2_stream.c b/modules/http2/h2_stream.c index 7db3b62912..08b8f5a3f8 100644 --- a/modules/http2/h2_stream.c +++ b/modules/http2/h2_stream.c @@ -139,9 +139,10 @@ static int set_closed(h2_stream *stream) apr_status_t h2_stream_rwrite(h2_stream *stream, request_rec *r) { + apr_status_t status; AP_DEBUG_ASSERT(stream); set_state(stream, H2_STREAM_ST_OPEN); - apr_status_t status = h2_request_rwrite(stream->request, r, stream->m); + status = h2_request_rwrite(stream->request, r, stream->m); return status; } diff --git a/modules/http2/h2_stream_set.c b/modules/http2/h2_stream_set.c index bf7fd62251..762b507ea0 100644 --- a/modules/http2/h2_stream_set.c +++ b/modules/http2/h2_stream_set.c @@ -65,10 +65,11 @@ h2_stream *h2_stream_set_get(h2_stream_set *sp, int stream_id) * by bsearch. */ h2_stream key; + h2_stream *pkey, **ps; memset(&key, 0, sizeof(key)); key.id = stream_id; - h2_stream *pkey = &key; - h2_stream **ps = bsearch(&pkey, sp->list->elts, sp->list->nelts, + pkey = &key; + ps = bsearch(&pkey, sp->list->elts, sp->list->nelts, sp->list->elt_size, h2_stream_id_cmp); return ps? *ps : NULL; } @@ -83,13 +84,14 @@ apr_status_t h2_stream_set_add(h2_stream_set *sp, h2_stream *stream) { h2_stream *existing = h2_stream_set_get(sp, stream->id); if (!existing) { + int last; APR_ARRAY_PUSH(sp->list, h2_stream*) = stream; /* Normally, streams get added in ascending order if id. We * keep the array sorted, so we just need to check of the newly * appended stream has a lower id than the last one. if not, * sorting is not necessary. */ - int last = sp->list->nelts - 1; + last = sp->list->nelts - 1; if (last > 0 && (H2_STREAM_IDX(sp->list, last)->id < H2_STREAM_IDX(sp->list, last-1)->id)) { @@ -104,8 +106,9 @@ h2_stream *h2_stream_set_remove(h2_stream_set *sp, h2_stream *stream) for (int i = 0; i < sp->list->nelts; ++i) { h2_stream *s = H2_STREAM_IDX(sp->list, i); if (s == stream) { + int n; --sp->list->nelts; - int n = sp->list->nelts - i; + n = sp->list->nelts - i; if (n > 0) { /* Close the hole in the array by moving the upper * parts down one step. diff --git a/modules/http2/h2_task.c b/modules/http2/h2_task.c index 15aae88024..09bc1472d1 100644 --- a/modules/http2/h2_task.c +++ b/modules/http2/h2_task.c @@ -114,7 +114,6 @@ void h2_task_register_hooks(void) static int h2_task_pre_conn(conn_rec* c, void *arg) { - (void)arg; h2_ctx *ctx = h2_ctx_get(c); if (h2_ctx_is_task(ctx)) { diff --git a/modules/http2/h2_task_output.c b/modules/http2/h2_task_output.c index b944d8ccb1..062d2d0dba 100644 --- a/modules/http2/h2_task_output.c +++ b/modules/http2/h2_task_output.c @@ -36,7 +36,6 @@ h2_task_output *h2_task_output_create(h2_task_env *env, apr_pool_t *pool, apr_bucket_alloc_t *bucket_alloc) { - (void)bucket_alloc; h2_task_output *output = apr_pcalloc(pool, sizeof(h2_task_output)); if (output) { output->env = env; @@ -61,8 +60,9 @@ static apr_status_t open_if_needed(h2_task_output *output, ap_filter_t *f, apr_bucket_brigade *bb) { if (output->state == H2_TASK_OUT_INIT) { + h2_response *response; output->state = H2_TASK_OUT_STARTED; - h2_response *response = h2_from_h1_get_response(output->from_h1); + response = h2_from_h1_get_response(output->from_h1); if (!response) { if (f) { /* This happens currently when ap_die(status, r) is invoked @@ -108,13 +108,14 @@ int h2_task_output_has_started(h2_task_output *output) apr_status_t h2_task_output_write(h2_task_output *output, 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->env->id); return APR_SUCCESS; } - apr_status_t status = open_if_needed(output, f, bb); + status = open_if_needed(output, f, bb); if (status != APR_EOF) { ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, f->c, "h2_task_output(%s): opened and passed brigade", diff --git a/modules/http2/h2_to_h1.c b/modules/http2/h2_to_h1.c index f8ac54c34c..f07c97c9ca 100644 --- a/modules/http2/h2_to_h1.c +++ b/modules/http2/h2_to_h1.c @@ -36,6 +36,7 @@ h2_to_h1 *h2_to_h1_create(int stream_id, apr_pool_t *pool, const char *method, const char *path, const char *authority, struct h2_mplx *m) { + h2_to_h1 *to_h1; if (!method) { ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, m->c, "h2_to_h1: header start but :method missing"); @@ -47,7 +48,7 @@ h2_to_h1 *h2_to_h1_create(int stream_id, apr_pool_t *pool, return NULL; } - h2_to_h1 *to_h1 = apr_pcalloc(pool, sizeof(h2_to_h1)); + to_h1 = apr_pcalloc(pool, sizeof(h2_to_h1)); if (to_h1) { to_h1->stream_id = stream_id; to_h1->pool = pool; @@ -72,6 +73,7 @@ apr_status_t h2_to_h1_add_header(h2_to_h1 *to_h1, const char *name, size_t nlen, const char *value, size_t vlen) { + char *hname, *hvalue; if (H2_HD_MATCH_LIT("transfer-encoding", name, nlen)) { if (!apr_strnatcasecmp("chunked", value)) { /* This should never arrive here in a HTTP/2 request */ @@ -123,8 +125,8 @@ apr_status_t h2_to_h1_add_header(h2_to_h1 *to_h1, to_h1->seen_host = 1; } - char *hname = apr_pstrndup(to_h1->pool, name, nlen); - char *hvalue = apr_pstrndup(to_h1->pool, value, vlen); + hname = apr_pstrndup(to_h1->pool, name, nlen); + hvalue = apr_pstrndup(to_h1->pool, value, vlen); h2_util_camel_case_header(hname, nlen); apr_table_mergen(to_h1->headers, hname, hvalue); diff --git a/modules/http2/h2_upgrade.c b/modules/http2/h2_upgrade.c index 88d94cb4b7..432c267f37 100644 --- a/modules/http2/h2_upgrade.c +++ b/modules/http2/h2_upgrade.c @@ -85,6 +85,7 @@ static int h2_upgrade_request_handler(request_rec *r) /* Check for the start of an h2c Upgrade dance. */ const char *proto = h2_get_upgrade_proto(r); if (proto) { + const char *clen; ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "seeing %s upgrade invitation", proto); /* We do not handle upgradeable requests with a body. @@ -94,7 +95,7 @@ static int h2_upgrade_request_handler(request_rec *r) * This seems to be consensus among server implemntations and * clients are advised to use an "OPTIONS *" before a POST. */ - const char *clen = apr_table_get(r->headers_in, "Content-Length"); + clen = apr_table_get(r->headers_in, "Content-Length"); if (clen && strcmp(clen, "0")) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "upgrade with content-length: %s, declined", clen); @@ -152,6 +153,7 @@ static int h2_upgrade_to(request_rec *r, const char *proto) { conn_rec *c = r->connection; h2_ctx *ctx = h2_ctx_rget(r); + apr_status_t status; h2_ctx_pnego_set_done(ctx, proto); @@ -179,7 +181,7 @@ static int h2_upgrade_to(request_rec *r, const char *proto) ap_remove_input_filter_byhandle(r->input_filters, "reqtimeout"); /* Ok, start an h2_conn on this one. */ - apr_status_t status = h2_conn_rprocess(r); + status = h2_conn_rprocess(r); if (status != DONE) { /* Nothing really to do about this. */ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, status, r, diff --git a/modules/http2/h2_util.c b/modules/http2/h2_util.c index 33f9d81dc4..e735996bc6 100644 --- a/modules/http2/h2_util.c +++ b/modules/http2/h2_util.c @@ -112,17 +112,19 @@ apr_size_t h2_util_base64url_decode(unsigned char **decoded, const char *encoded { const unsigned char *e = (const unsigned char *)encoded; const unsigned char *p = e; + unsigned char *d; int n; + apr_size_t len, mlen, remain, i; while (*p && BASE64URL_TABLE[ *p ] == -1) { ++p; } - apr_size_t len = p - e; - apr_size_t mlen = (len/4)*4; + len = p - e; + mlen = (len/4)*4; *decoded = apr_pcalloc(pool, len+1); - apr_size_t i = 0; - unsigned char *d = *decoded; + i = 0; + d = *decoded; for (; i < mlen; i += 4) { n = ((BASE64URL_TABLE[ e[i+0] ] << 18) + (BASE64URL_TABLE[ e[i+1] ] << 12) + @@ -132,7 +134,7 @@ apr_size_t h2_util_base64url_decode(unsigned char **decoded, const char *encoded *d++ = n >> 8 & 0xffu; *d++ = n & 0xffu; } - apr_size_t remain = len - mlen; + remain = len - mlen; switch (remain) { case 2: n = ((BASE64URL_TABLE[ e[mlen+0] ] << 18) + @@ -271,10 +273,11 @@ apr_status_t h2_util_move(apr_bucket_brigade *to, apr_bucket_brigade *from, const char *msg) { apr_status_t status = APR_SUCCESS; + int same_alloc; AP_DEBUG_ASSERT(to); AP_DEBUG_ASSERT(from); - int same_alloc = (to->bucket_alloc == from->bucket_alloc); + same_alloc = (to->bucket_alloc == from->bucket_alloc); if (!FILE_MOVE) { pfile_handles_allowed = NULL; @@ -400,11 +403,11 @@ apr_status_t h2_util_copy(apr_bucket_brigade *to, apr_bucket_brigade *from, apr_size_t maxlen, const char *msg) { apr_status_t status = APR_SUCCESS; - (void)msg; + int same_alloc; AP_DEBUG_ASSERT(to); AP_DEBUG_ASSERT(from); - int same_alloc = (to->bucket_alloc == from->bucket_alloc); + same_alloc = (to->bucket_alloc == from->bucket_alloc); if (!APR_BRIGADE_EMPTY(from)) { apr_bucket *b, *end, *cpy; diff --git a/modules/http2/h2_worker.c b/modules/http2/h2_worker.c index 2e2a1d4ed7..1466a61907 100644 --- a/modules/http2/h2_worker.c +++ b/modules/http2/h2_worker.c @@ -79,6 +79,7 @@ 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_allocator_create(&allocator); if (status != APR_SUCCESS) { @@ -91,7 +92,7 @@ h2_worker *h2_worker_create(int id, } apr_allocator_owner_set(allocator, pool); - h2_worker *w = apr_pcalloc(pool, sizeof(h2_worker)); + w = apr_pcalloc(pool, sizeof(h2_worker)); if (w) { APR_RING_ELEM_INIT(w, link); diff --git a/modules/http2/h2_workers.c b/modules/http2/h2_workers.c index 6bdf965e80..f446cd237c 100644 --- a/modules/http2/h2_workers.c +++ b/modules/http2/h2_workers.c @@ -238,11 +238,13 @@ static apr_status_t h2_workers_start(h2_workers *workers) { h2_workers *h2_workers_create(server_rec *s, apr_pool_t *pool, int min_size, int max_size) { + apr_status_t status; + h2_workers *workers; AP_DEBUG_ASSERT(s); AP_DEBUG_ASSERT(pool); - apr_status_t status = APR_SUCCESS; + status = APR_SUCCESS; - h2_workers *workers = apr_pcalloc(pool, sizeof(h2_workers)); + workers = apr_pcalloc(pool, sizeof(h2_workers)); if (workers) { workers->s = s; workers->pool = pool; diff --git a/modules/http2/mod_h2.c b/modules/http2/mod_h2.c index b3c6b187d1..4588bde2fa 100644 --- a/modules/http2/mod_h2.c +++ b/modules/http2/mod_h2.c @@ -129,10 +129,10 @@ const char *h2_get_protocol(conn_rec *c) */ static void h2_hooks(apr_pool_t *pool) { - ap_log_perror(APLOG_MARK, APLOG_INFO, 0, pool, "installing hooks"); - static const char *const mod_ssl[] = { "mod_ssl.c", NULL}; + ap_log_perror(APLOG_MARK, APLOG_INFO, 0, pool, "installing hooks"); + /* Run once after configuration is set, but before mpm children initialize. */ ap_hook_post_config(h2_post_config, mod_ssl, NULL, APR_HOOK_MIDDLE);