Skip to content

Commit

Permalink
more apr_uint32_t usage where appropriate, signed/unsigned warning de…
Browse files Browse the repository at this point in the history
…tox, stream reset clears buffers immediately

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1761548 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
icing committed Sep 20, 2016
1 parent aeb21d7 commit 0ff536a
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 30 deletions.
4 changes: 2 additions & 2 deletions modules/http2/h2.h
Expand Up @@ -115,8 +115,8 @@ typedef struct h2_session_props {
typedef struct h2_request h2_request;

struct h2_request {
int id; /* stream id */
int initiated_on; /* initiating stream id (PUSH) or 0 */
apr_uint32_t id; /* stream id */
apr_uint32_t initiated_on; /* initiating stream id (PUSH) or 0 */

const char *method; /* pseudo header values, see ch. 8.1.2.3 */
const char *scheme;
Expand Down
10 changes: 5 additions & 5 deletions modules/http2/h2_bucket_beam.c
Expand Up @@ -245,9 +245,9 @@ static void report_production(h2_bucket_beam *beam, int force)
}
}

static apr_off_t calc_buffered(h2_bucket_beam *beam)
static apr_size_t calc_buffered(h2_bucket_beam *beam)
{
apr_off_t len = 0;
apr_size_t len = 0;
apr_bucket *b;
for (b = H2_BLIST_FIRST(&beam->red);
b != H2_BLIST_SENTINEL(&beam->red);
Expand Down Expand Up @@ -296,7 +296,7 @@ static apr_status_t wait_cond(h2_bucket_beam *beam, apr_thread_mutex_t *lock)
}

static apr_status_t r_wait_space(h2_bucket_beam *beam, apr_read_type_e block,
h2_beam_lock *pbl, apr_off_t *premain)
h2_beam_lock *pbl, apr_size_t *premain)
{
*premain = calc_space_left(beam);
while (!beam->aborted && *premain <= 0
Expand Down Expand Up @@ -428,7 +428,7 @@ apr_status_t h2_beam_destroy(h2_bucket_beam *beam)
}

apr_status_t h2_beam_create(h2_bucket_beam **pbeam, apr_pool_t *red_pool,
int id, const char *tag,
apr_uint32_t id, const char *tag,
apr_size_t max_buf_size)
{
h2_bucket_beam *beam;
Expand Down Expand Up @@ -585,7 +585,7 @@ static apr_status_t append_bucket(h2_bucket_beam *beam,
{
const char *data;
apr_size_t len;
apr_off_t space_left = 0;
apr_size_t space_left = 0;
apr_status_t status;

if (APR_BUCKET_IS_METADATA(bred)) {
Expand Down
4 changes: 2 additions & 2 deletions modules/http2/h2_bucket_beam.h
Expand Up @@ -170,7 +170,7 @@ typedef int h2_beam_can_beam_callback(void *ctx, h2_bucket_beam *beam,
int h2_beam_no_files(void *ctx, h2_bucket_beam *beam, apr_file_t *file);

struct h2_bucket_beam {
int id;
apr_uint32_t id;
const char *tag;
h2_blist red;
h2_blist hold;
Expand Down Expand Up @@ -223,7 +223,7 @@ struct h2_bucket_beam {
*/
apr_status_t h2_beam_create(h2_bucket_beam **pbeam,
apr_pool_t *red_pool,
int id, const char *tag,
apr_uint32_t id, const char *tag,
apr_size_t buffer_size);

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/http2/h2_conn_io.c
Expand Up @@ -132,7 +132,7 @@ apr_status_t h2_conn_io_init(h2_conn_io *io, conn_rec *c,
io->output = apr_brigade_create(c->pool, c->bucket_alloc);
io->is_tls = h2_h2_is_tls(c);
io->buffer_output = io->is_tls;
io->pass_threshold = h2_config_geti64(cfg, H2_CONF_STREAM_MAX_MEM) / 2;
io->pass_threshold = (apr_size_t)h2_config_geti64(cfg, H2_CONF_STREAM_MAX_MEM) / 2;

if (io->is_tls) {
/* This is what we start with,
Expand Down
11 changes: 9 additions & 2 deletions modules/http2/h2_mplx.c
Expand Up @@ -45,7 +45,7 @@
#include "h2_util.h"


static void h2_beam_log(h2_bucket_beam *beam, int id, const char *msg,
static void h2_beam_log(h2_bucket_beam *beam, apr_uint32_t id, const char *msg,
conn_rec *c, int level)
{
if (beam && APLOG_C_IS_LEVEL(c,level)) {
Expand Down Expand Up @@ -749,11 +749,18 @@ static apr_status_t out_open(h2_mplx *m, int stream_id, h2_response *response)
}

if (task->output.beam && !task->output.opened) {
apr_uint32_t beamed_count;
h2_beam_buffer_size_set(task->output.beam, m->stream_max_mem);
h2_beam_timeout_set(task->output.beam, m->stream_timeout);
h2_beam_on_consumed(task->output.beam, stream_output_consumed, task);
h2_beam_on_produced(task->output.beam, output_produced, m);
m->tx_handles_reserved -= h2_beam_get_files_beamed(task->output.beam);
beamed_count = h2_beam_get_files_beamed(task->output.beam);
if (m->tx_handles_reserved >= beamed_count) {
m->tx_handles_reserved -= beamed_count;
}
else {
m->tx_handles_reserved = 0;
}
if (!task->output.copy_files) {
h2_beam_on_file_beam(task->output.beam, can_beam_file, m);
}
Expand Down
4 changes: 2 additions & 2 deletions modules/http2/h2_mplx.h
Expand Up @@ -105,8 +105,8 @@ struct h2_mplx {
apr_array_header_t *spare_slaves; /* spare slave connections */

struct h2_workers *workers;
int tx_handles_reserved;
apr_size_t tx_chunk_size;
apr_uint32_t tx_handles_reserved;
apr_uint32_t tx_chunk_size;

h2_mplx_consumed_cb *input_consumed;
void *input_consumed_ctx;
Expand Down
4 changes: 2 additions & 2 deletions modules/http2/h2_push.h
Expand Up @@ -38,8 +38,8 @@ typedef void h2_push_digest_calc(h2_push_diary *diary, apr_uint64_t *phash, h2_p

struct h2_push_diary {
apr_array_header_t *entries;
apr_size_t NMax; /* Maximum for N, should size change be necessary */
apr_size_t N; /* Current maximum number of entries, power of 2 */
apr_uint32_t NMax; /* Maximum for N, should size change be necessary */
apr_uint32_t N; /* Current maximum number of entries, power of 2 */
apr_uint64_t mask; /* mask for relevant bits */
unsigned int mask_bits; /* number of relevant bits */
const char *authority;
Expand Down
15 changes: 13 additions & 2 deletions modules/http2/h2_session.c
Expand Up @@ -1303,7 +1303,8 @@ apr_status_t h2_session_set_prio(h2_session *session, h2_stream *stream,
s_parent = nghttp2_stream_get_parent(s);
if (s_parent) {
nghttp2_priority_spec ps;
int id_parent, id_grandpa, w_parent, w, rv = 0;
apr_uint32_t id_parent, id_grandpa, w_parent, w;
int rv = 0;
char *ptype = "AFTER";
h2_dependency dep = prio->dependency;

Expand Down Expand Up @@ -1433,7 +1434,17 @@ static apr_status_t on_stream_resume(void *ctx, int stream_id)
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
"h2_stream(%ld-%d): on_resume", session->id, stream_id);
if (stream) {
int rv = nghttp2_session_resume_data(session->ngh2, stream_id);
int rv;
if (stream->rst_error) {
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO()
"h2_stream(%ld-%d): RST_STREAM, err=%d",
session->id, stream->id, stream->rst_error);
rv = nghttp2_submit_rst_stream(session->ngh2, NGHTTP2_FLAG_NONE,
stream->id, stream->rst_error);
}
else {
rv = nghttp2_session_resume_data(session->ngh2, stream_id);
}
session->have_written = 1;
ap_log_cerror(APLOG_MARK, nghttp2_is_fatal(rv)?
APLOG_ERR : APLOG_DEBUG, 0, session->c,
Expand Down
5 changes: 4 additions & 1 deletion modules/http2/h2_stream.c
Expand Up @@ -174,7 +174,7 @@ static apr_status_t stream_pool_cleanup(void *ctx)
return APR_SUCCESS;
}

h2_stream *h2_stream_open(int id, apr_pool_t *pool, h2_session *session,
h2_stream *h2_stream_open(apr_uint32_t id, apr_pool_t *pool, h2_session *session,
int initiated_on)
{
h2_stream *stream = apr_pcalloc(pool, sizeof(h2_stream));
Expand Down Expand Up @@ -244,6 +244,9 @@ void h2_stream_rst(h2_stream *stream, int error_code)
stream->rst_error = error_code;
close_input(stream);
close_output(stream);
if (stream->buffer) {
apr_brigade_cleanup(stream->buffer);
}
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c,
"h2_stream(%ld-%d): reset, error=%d",
stream->session->id, stream->id, error_code);
Expand Down
6 changes: 3 additions & 3 deletions modules/http2/h2_stream.h
Expand Up @@ -42,8 +42,8 @@ struct h2_bucket_beam;
typedef struct h2_stream h2_stream;

struct h2_stream {
int id; /* http2 stream id */
int initiated_on; /* initiating stream id (PUSH) or 0 */
apr_uint32_t id; /* http2 stream id */
apr_uint32_t initiated_on; /* initiating stream id (PUSH) or 0 */
apr_time_t created; /* when stream was created */
h2_stream_state_t state; /* http/2 state of this stream */
struct h2_session *session; /* the session this stream belongs to */
Expand Down Expand Up @@ -84,7 +84,7 @@ struct h2_stream {
* @param session the session this stream belongs to
* @return the newly opened stream
*/
h2_stream *h2_stream_open(int id, apr_pool_t *pool, struct h2_session *session,
h2_stream *h2_stream_open(apr_uint32_t id, apr_pool_t *pool, struct h2_session *session,
int initiated_on);

/**
Expand Down
6 changes: 4 additions & 2 deletions modules/http2/h2_task.c
Expand Up @@ -144,6 +144,8 @@ static apr_status_t input_read(h2_task *task, ap_filter_t* f,
apr_status_t status = APR_SUCCESS;
apr_bucket *b, *next, *first_data;
apr_off_t bblen = 0;
apr_size_t rmax = ((readbytes <= APR_SIZE_MAX)?
(apr_size_t)readbytes : APR_SIZE_MAX);

ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, f->c,
"h2_task(%s): read, mode=%d, block=%d, readbytes=%ld",
Expand Down Expand Up @@ -288,10 +290,10 @@ static apr_status_t input_read(h2_task *task, ap_filter_t* f,
APR_BRIGADE_CONCAT(bb, task->input.bb);
}
else if (mode == AP_MODE_READBYTES) {
status = h2_brigade_concat_length(bb, task->input.bb, readbytes);
status = h2_brigade_concat_length(bb, task->input.bb, rmax);
}
else if (mode == AP_MODE_SPECULATIVE) {
status = h2_brigade_copy_length(bb, task->input.bb, readbytes);
status = h2_brigade_copy_length(bb, task->input.bb, rmax);
}
else if (mode == AP_MODE_GETLINE) {
/* we are reading a single LF line, e.g. the HTTP headers.
Expand Down
2 changes: 1 addition & 1 deletion modules/http2/h2_task.h
Expand Up @@ -51,7 +51,7 @@ typedef struct h2_task h2_task;

struct h2_task {
const char *id;
int stream_id;
apr_uint32_t stream_id;
conn_rec *c;
apr_pool_t *pool;

Expand Down
10 changes: 5 additions & 5 deletions modules/http2/h2_util.c
Expand Up @@ -653,8 +653,8 @@ static apr_status_t last_not_included(apr_bucket_brigade *bb,
* unless we do not move the file buckets */
--files_allowed;
}
else if (maxlen < b->length) {
apr_bucket_split(b, maxlen);
else if (maxlen < (apr_off_t)b->length) {
apr_bucket_split(b, (apr_size_t)maxlen);
maxlen = 0;
}
else {
Expand Down Expand Up @@ -852,7 +852,7 @@ apr_status_t h2_util_bb_readx(apr_bucket_brigade *bb,

if (data_len > avail) {
apr_bucket_split(b, avail);
data_len = avail;
data_len = (apr_size_t)avail;
}

if (consume) {
Expand Down Expand Up @@ -1004,7 +1004,7 @@ apr_status_t h2_append_brigade(apr_bucket_brigade *to,
if (remain <= 0) {
return APR_SUCCESS;
}
apr_bucket_split(e, remain);
apr_bucket_split(e, (apr_size_t)remain);
}
}

Expand Down Expand Up @@ -1202,7 +1202,7 @@ static int ignore_header(const literal *lits, size_t llen,
const char *name, size_t nlen)
{
const literal *lit;
int i;
size_t i;

for (i = 0; i < llen; ++i) {
lit = &lits[i];
Expand Down

0 comments on commit 0ff536a

Please sign in to comment.