Commit 64b98f99 authored by Stefan Eissing's avatar Stefan Eissing
Browse files

mod_http2: bringing some signed/unsigned casting goodness, aligning with github mod-h2 again


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1843424 13f79535-47bb-0310-9956-ffa450edef68
parent 3c485337
Loading
Loading
Loading
Loading
+2 −2
Changes for modules/http2/h2_alt_svc.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -46,14 +46,14 @@ h2_alt_svc *h2_alt_svc_parse(const char *s, apr_pool_t *pool)
{
    const char *sep = ap_strchr_c(s, '=');
    if (sep) {
        const char *alpn = apr_pstrmemdup(pool, s, sep - s);
        const char *alpn = apr_pstrmemdup(pool, s, (apr_size_t)(sep - s));
        const char *host = NULL;
        int port = 0;
        s = sep + 1;
        sep = ap_strchr_c(s, ':');  /* mandatory : */
        if (sep) {
            if (sep != s) {    /* optional host */
                host = apr_pstrmemdup(pool, s, sep - s);
                host = apr_pstrmemdup(pool, s, (apr_size_t)(sep - s));
            }
            s = sep + 1;
            if (*s) {          /* must be a port number */
+13 −8
Changes for modules/http2/h2_bucket_beam.c: 13 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -198,6 +198,7 @@ static apr_bucket *h2_beam_bucket(h2_bucket_beam *beam,

static void mutex_leave(void *ctx, apr_thread_mutex_t *lock)
{
    (void)ctx;
    apr_thread_mutex_unlock(lock);
}

@@ -216,6 +217,7 @@ static apr_status_t enter_yellow(h2_bucket_beam *beam, h2_beam_lock *pbl)

static void leave_yellow(h2_bucket_beam *beam, h2_beam_lock *pbl)
{
    (void)beam;
    if (pbl->leave) {
        pbl->leave(pbl->leave_ctx, pbl->mutex);
    }
@@ -228,7 +230,7 @@ static apr_off_t bucket_mem_used(apr_bucket *b)
    }
    else {
        /* should all have determinate length */
        return b->length;
        return (apr_off_t)b->length;
    }
}

@@ -302,7 +304,7 @@ static void r_purge_sent(h2_bucket_beam *beam)
static apr_size_t calc_space_left(h2_bucket_beam *beam)
{
    if (beam->max_buf_size > 0) {
        apr_off_t len = calc_buffered(beam);
        apr_size_t len = calc_buffered(beam);
        return (beam->max_buf_size > len? (beam->max_buf_size - len) : 0);
    }
    return APR_SIZE_MAX;
@@ -777,6 +779,8 @@ static apr_status_t append_bucket(h2_bucket_beam *beam,
    apr_status_t status;
    int can_beam = 0, check_len;
    
    (void)block;
    (void)pbl;
    if (beam->aborted) {
        return APR_ECONNABORTED;
    }
@@ -815,8 +819,8 @@ static apr_status_t append_bucket(h2_bucket_beam *beam,
    }
    else {
        if (b->length == ((apr_size_t)-1)) {
            const char *data;
            status = apr_bucket_read(b, &data, &len, APR_BLOCK_READ);
            const char *data2;
            status = apr_bucket_read(b, &data2, &len, APR_BLOCK_READ);
            if (status != APR_SUCCESS) {
                return status;
            }
@@ -957,7 +961,7 @@ apr_status_t h2_beam_receive(h2_bucket_beam *beam,
    /* Called from the receiver thread to take buckets from the beam */
    if (enter_yellow(beam, &bl) == APR_SUCCESS) {
        if (readbytes <= 0) {
            readbytes = APR_SIZE_MAX;
            readbytes = (apr_off_t)APR_SIZE_MAX;
        }
        remain = readbytes;
        
@@ -1027,7 +1031,7 @@ transfer:
                    }
                    ++beam->files_beamed;
                }
                ng = apr_brigade_insert_file(bb, fd, bsender->start, bsender->length, 
                ng = apr_brigade_insert_file(bb, fd, bsender->start, (apr_off_t)bsender->length, 
                                             bb->p);
#if APR_HAS_MMAP
                /* disable mmap handling as this leads to segfaults when
@@ -1087,9 +1091,9 @@ transfer:
                 brecv != APR_BRIGADE_SENTINEL(bb);
                 brecv = APR_BUCKET_NEXT(brecv)) {
                remain -= (beam->tx_mem_limits? bucket_mem_used(brecv) 
                           : brecv->length);
                           : (apr_off_t)brecv->length);
                if (remain < 0) {
                    apr_bucket_split(brecv, brecv->length+remain);
                    apr_bucket_split(brecv, (apr_size_t)((apr_off_t)brecv->length+remain));
                    beam->recv_buffer = apr_brigade_split_ex(bb, 
                                                             APR_BUCKET_NEXT(brecv), 
                                                             beam->recv_buffer);
@@ -1255,6 +1259,7 @@ apr_size_t h2_beam_get_files_beamed(h2_bucket_beam *beam)

int h2_beam_no_files(void *ctx, h2_bucket_beam *beam, apr_file_t *file)
{
    (void)ctx; (void)beam; (void)file;
    return 0;
}

+5 −2
Changes for modules/http2/h2_config.c: 5 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ const struct h2_priority *h2_config_get_priority(const h2_config *conf,
                                                 const char *content_type)
{
    if (content_type && conf->priorities) {
        size_t len = strcspn(content_type, "; \t");
        apr_ssize_t len = (apr_ssize_t)strcspn(content_type, "; \t");
        h2_priority *prio = apr_hash_get(conf->priorities, content_type, len);
        return prio? prio : apr_hash_get(conf->priorities, "*", 1);
    }
@@ -401,6 +401,7 @@ static const char *h2_conf_add_push_priority(cmd_parms *cmd, void *_cfg,
    h2_priority *priority;
    int weight;
 
    (void)_cfg;
    if (!*ctype) {
        return "1st argument must be a mime-type, like 'text/css' or '*'";
    }
@@ -443,7 +444,7 @@ static const char *h2_conf_add_push_priority(cmd_parms *cmd, void *_cfg,
    if (!cfg->priorities) {
        cfg->priorities = apr_hash_make(cmd->pool);
    }
    apr_hash_set(cfg->priorities, ctype, strlen(ctype), priority);
    apr_hash_set(cfg->priorities, ctype, (apr_ssize_t)strlen(ctype), priority);
    return NULL;
}

@@ -521,6 +522,8 @@ static const char *h2_conf_set_copy_files(cmd_parms *parms,
                                          void *arg, const char *value)
{
    h2_config *cfg = (h2_config *)arg;
    
    (void)parms;
    if (!strcasecmp(value, "On")) {
        cfg->copy_files = 1;
        return NULL;
+2 −0
Changes for modules/http2/h2_conn.c: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -250,6 +250,8 @@ apr_status_t h2_conn_run(struct h2_ctx *ctx, conn_rec *c)
apr_status_t h2_conn_pre_close(struct h2_ctx *ctx, conn_rec *c)
{
    h2_session *session = h2_ctx_session_get(ctx);
    
    (void)c;
    if (session) {
        apr_status_t status = h2_session_pre_close(session, async_mpm);
        return (status == APR_SUCCESS)? DONE : status;
+14 −13
Changes for modules/http2/h2_conn_io.c: 14 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -47,16 +47,18 @@
 */
#define WRITE_SIZE_MAX        (TLS_DATA_MAX - 100) 

#define BUF_REMAIN            ((apr_size_t)(bmax-off))

static void h2_conn_io_bb_log(conn_rec *c, int stream_id, int level, 
                              const char *tag, apr_bucket_brigade *bb)
{
    char buffer[16 * 1024];
    const char *line = "(null)";
    apr_size_t bmax = sizeof(buffer)/sizeof(buffer[0]);
    int bmax = sizeof(buffer)/sizeof(buffer[0]);
    int off = 0;
    apr_bucket *b;
    
    (void)stream_id;
    if (bb) {
        memset(buffer, 0, bmax--);
        for (b = APR_BRIGADE_FIRST(bb); 
@@ -65,19 +67,19 @@ static void h2_conn_io_bb_log(conn_rec *c, int stream_id, int level,
            
            if (APR_BUCKET_IS_METADATA(b)) {
                if (APR_BUCKET_IS_EOS(b)) {
                    off += apr_snprintf(buffer+off, bmax-off, "eos ");
                    off += apr_snprintf(buffer+off, BUF_REMAIN, "eos ");
                }
                else if (APR_BUCKET_IS_FLUSH(b)) {
                    off += apr_snprintf(buffer+off, bmax-off, "flush ");
                    off += apr_snprintf(buffer+off, BUF_REMAIN, "flush ");
                }
                else if (AP_BUCKET_IS_EOR(b)) {
                    off += apr_snprintf(buffer+off, bmax-off, "eor ");
                    off += apr_snprintf(buffer+off, BUF_REMAIN, "eor ");
                }
                else if (H2_BUCKET_IS_H2EOS(b)) {
                    off += apr_snprintf(buffer+off, bmax-off, "h2eos ");
                    off += apr_snprintf(buffer+off, BUF_REMAIN, "h2eos ");
                }
                else {
                    off += apr_snprintf(buffer+off, bmax-off, "meta(unknown) ");
                    off += apr_snprintf(buffer+off, BUF_REMAIN, "meta(unknown) ");
                }
            }
            else {
@@ -109,10 +111,9 @@ static void h2_conn_io_bb_log(conn_rec *c, int stream_id, int level,
                    btype = "pool";
                }
                
                off += apr_snprintf(buffer+off, bmax-off, "%s[%ld] ", 
                off += apr_snprintf(buffer+off, BUF_REMAIN, "%s[%ld] ", 
                                    btype, 
                                    (long)(b->length == ((apr_size_t)-1)? 
                                           -1 : b->length));
                                    (long)(b->length == ((apr_size_t)-1)? -1UL : b->length));
            }
        }
        line = *buffer? buffer : "(empty)";
@@ -153,7 +154,7 @@ apr_status_t h2_conn_io_init(h2_conn_io *io, conn_rec *c,
                      "h2_conn_io(%ld): init, buffering=%d, warmup_size=%ld, "
                      "cd_secs=%f", io->c->id, io->buffer_output, 
                      (long)io->warmup_size,
                      ((float)io->cooldown_usecs/APR_USEC_PER_SEC));
                      ((double)io->cooldown_usecs/APR_USEC_PER_SEC));
    }

    return APR_SUCCESS;
@@ -202,8 +203,8 @@ static apr_status_t read_to_scratch(h2_conn_io *io, apr_bucket *b)
        apr_bucket_file *f = (apr_bucket_file *)b->data;
        apr_file_t *fd = f->fd;
        apr_off_t offset = b->start;
        apr_size_t len = b->length;
        
        len = b->length;
        /* file buckets will either mmap (which we do not want) or
         * read 8000 byte chunks and split themself. However, we do
         * know *exactly* how many bytes we need where.
@@ -288,13 +289,13 @@ int h2_conn_io_needs_flush(h2_conn_io *io)
{
    if (!io->is_flushed) {
        apr_off_t len = h2_brigade_mem_size(io->output);
        if (len > io->flush_threshold) {
        if (len > (apr_off_t)io->flush_threshold) {
            return 1;
        }
        /* if we do not exceed flush length due to memory limits,
         * we want at least flush when we have that amount of data. */
        apr_brigade_length(io->output, 0, &len);
        return len > (4 * io->flush_threshold);
        return len > (apr_off_t)(4 * io->flush_threshold);
    }
    return 0;
}
Loading