]> granicus.if.org Git - apache/commitdiff
more apr_uint32_t usage where appropriate, signed/unsigned warning detox, stream...
authorStefan Eissing <icing@apache.org>
Tue, 20 Sep 2016 10:12:22 +0000 (10:12 +0000)
committerStefan Eissing <icing@apache.org>
Tue, 20 Sep 2016 10:12:22 +0000 (10:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1761548 13f79535-47bb-0310-9956-ffa450edef68

13 files changed:
modules/http2/h2.h
modules/http2/h2_bucket_beam.c
modules/http2/h2_bucket_beam.h
modules/http2/h2_conn_io.c
modules/http2/h2_mplx.c
modules/http2/h2_mplx.h
modules/http2/h2_push.h
modules/http2/h2_session.c
modules/http2/h2_stream.c
modules/http2/h2_stream.h
modules/http2/h2_task.c
modules/http2/h2_task.h
modules/http2/h2_util.c

index d7bd70ecfc29df84e1c0c283b63b5329de1fed29..b8eac1046ced604b19f8cab72ffdc6299b545b30 100644 (file)
@@ -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;
index b1d698e796191195a6ed29f274648d4440454f22..01347363eed58a1e22ec84aee0be2903d19dafda 100644 (file)
@@ -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);
@@ -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 
@@ -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;
@@ -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)) {
index 8ccd8a3aaa7f1675334744e192d8899dde237583..1e486e9a243f4404efa28be19e4b54bb6208a601 100644 (file)
@@ -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;
@@ -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);
 
 /**
index 3f151f85785a9ad116e74e301bf4a1e04a7841a3..d72cbe4967ebef7c8a08764406360c0e780b55a1 100644 (file)
@@ -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, 
index dd0f0fdd29881a3b8ac78dd3e0dc4e4ec7612458..d5de4fe17f50159ef82948f1f3cdf742315e785a 100644 (file)
@@ -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)) {
@@ -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);
         }
index b2873e882769df934f5cde8024dc086551513734..229518cb219427eeb39977bc513471673415858d 100644 (file)
@@ -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;
index 62f5a0a78fdcf2a5becdbedd192c044da140b935..ae1ff6281aed3b63f8a4cb728fa80b61e4d5e510 100644 (file)
@@ -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;
index 1504073eafd8c9898c7e931933c9adfe91a58904..5d19d338844e3ad356b9651b1730b6c9c75345e4 100644 (file)
@@ -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;
         
@@ -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,
index 02e1a1274139ff65fbaada7c64584d435e0eefb2..7720237b10f1b996780a875950dd70eeed264617 100644 (file)
@@ -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));
@@ -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);
index de917e00d49e122bff81091d34adde504ee4db4e..e871cb7ee2b9f3983d0c0b3904de0e26f7790eb7 100644 (file)
@@ -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 */
@@ -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);
 
 /**
index c22471d27f601d02eb62ca86b2a4b5d9a3c18ab8..87ab619acca80f99fd5dd1a078d14e89ce3f9234 100644 (file)
@@ -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", 
@@ -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. 
index f13366e26cdf79a67ed7e8138ea177e4a4ee0247..85b530fa3f521c5194f98f29c25a1cb29d2cf86a 100644 (file)
@@ -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;
     
index bccf801f8bf88b5be03bda79857d04ae50dc6347..16c90a639ae0d944636ae1285e69d80ed7766de0 100644 (file)
@@ -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 {
@@ -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) {
@@ -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);
             }
         }
         
@@ -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];