From 5b71e358f3d86273c911a9577c20a983459c29e1 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Thu, 26 Jul 2001 15:53:15 +0000 Subject: [PATCH] Change the length of the content args to apr_off_t identifiers, and fix mod_negotation to treat a size of -1 and indeterminate, instead of 0. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89727 13f79535-47bb-0310-9956-ffa450edef68 --- include/http_protocol.h | 4 ++-- include/httpd.h | 8 ++++---- include/scoreboard.h | 6 +++--- modules/http/http_protocol.c | 4 ++-- modules/loggers/mod_log_config.c | 2 +- modules/mappers/mod_negotiation.c | 33 ++++++++++++++++--------------- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/include/http_protocol.h b/include/http_protocol.h index 10250e04e06..1d7a26a6ba1 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -413,9 +413,9 @@ AP_DECLARE(int) ap_should_client_block(request_rec *r); * @param bufsiz The size of the buffer * @return Number of bytes inserted into the buffer. When done reading, 0 * if EOF, or -1 if there was an error - * @deffunc long ap_get_client_block(request_rec *r, char *buffer, int bufsiz) + * @deffunc long ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz) */ -AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz); +AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz); /** * In HTTP/1.1, any method can have a body. However, most GET handlers diff --git a/include/httpd.h b/include/httpd.h index 3220d9938ee..c2eba3bc8fb 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -686,9 +686,9 @@ struct request_rec { ap_method_list_t *allowed_methods; /** byte count in stream is for body */ - int sent_bodyct; + apr_off_t sent_bodyct; /** body byte count, for easy access */ - long bytes_sent; + apr_off_t bytes_sent; /** Time the resource was last modified */ apr_time_t mtime; @@ -704,9 +704,9 @@ struct request_rec { apr_off_t clength; /** bytes left to read */ - apr_size_t remaining; + apr_off_t remaining; /** bytes that have been read */ - long read_length; + apr_off_t read_length; /** how the request body should be read */ int read_body; /** reading chunked transfer-coding */ diff --git a/include/scoreboard.h b/include/scoreboard.h index d521a93747b..2f6c32c9f82 100644 --- a/include/scoreboard.h +++ b/include/scoreboard.h @@ -148,10 +148,10 @@ struct worker_score { #endif unsigned char status; unsigned long access_count; - unsigned long bytes_served; + apr_off_t bytes_served; unsigned long my_access_count; - unsigned long my_bytes_served; - unsigned long conn_bytes; + apr_off_t my_bytes_served; + apr_off_t conn_bytes; unsigned short conn_count; apr_time_t start_time; apr_time_t stop_time; diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 4e1be8ce42e..b8f4b03da5e 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -558,7 +558,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode } else { const char *c = str; - while (c - str < length) { + while (c < str + length) { if (*c == APR_ASCII_LF) c++; else if (*c == APR_ASCII_CR && *(c + 1) == APR_ASCII_LF) @@ -1422,7 +1422,7 @@ static long get_chunk_size(char *b) * hold a chunk-size line, including any extensions. For now, we'll leave * that to the caller, at least until we can come up with a better solution. */ -AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz) +AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz) { apr_size_t len_read, total; apr_status_t rv; diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c index c42fdb03c6a..a1ffcc5c694 100644 --- a/modules/loggers/mod_log_config.c +++ b/modules/loggers/mod_log_config.c @@ -381,7 +381,7 @@ static const char *clf_log_bytes_sent(request_rec *r, char *a) return "-"; } else { - return apr_ltoa(r->pool, r->bytes_sent); + return apr_off_t_toa(r->pool, r->bytes_sent); } } diff --git a/modules/mappers/mod_negotiation.c b/modules/mappers/mod_negotiation.c index 4e56648a694..8773a874df0 100644 --- a/modules/mappers/mod_negotiation.c +++ b/modules/mappers/mod_negotiation.c @@ -204,7 +204,7 @@ typedef struct var_rec { /* Now some special values */ float level; /* Auxiliary to content-type... */ - long bytes; /* content length, if known */ + apr_off_t bytes; /* content length, if known */ int lang_index; /* pre HTTP/1.1 language priority stuff */ int is_pseudo_html; /* text/html, *or* the INCLUDES_MAGIC_TYPEs */ @@ -266,7 +266,7 @@ static void clean_var_rec(var_rec *mime_info) mime_info->is_pseudo_html = 0; mime_info->level = 0.0f; mime_info->level_matched = 0.0f; - mime_info->bytes = 0; + mime_info->bytes = -1; mime_info->lang_index = -1; mime_info->mime_stars = 0; mime_info->definite = 1; @@ -1451,23 +1451,24 @@ static void set_language_quality(negotiation_state *neg, var_rec *variant) /* Determining the content length --- if the map didn't tell us, * we have to do a stat() and remember for next time. - * - * Grump. For Apache, even the first stat here may well be - * redundant (for multiviews) with a stat() done by the sub_req - * machinery. At some point, that ought to be fixed. */ -static long find_content_length(negotiation_state *neg, var_rec *variant) +static apr_off_t find_content_length(negotiation_state *neg, var_rec *variant) { apr_finfo_t statb; - if (variant->bytes == 0) { - char *fullname = ap_make_full_path(neg->pool, neg->dir_name, - variant->file_name); + if (variant->bytes < 0) { + if (variant->sub_req && (variant->sub_req->finfo.valid & APR_FINFO_SIZE)) { + variant->bytes = variant->sub_req->finfo.size; + } + else { + char *fullname = ap_make_full_path(neg->pool, neg->dir_name, + variant->file_name); - if (apr_stat(&statb, fullname, - APR_FINFO_SIZE, neg->pool) == APR_SUCCESS) { - variant->bytes = statb.size; + if (apr_stat(&statb, fullname, + APR_FINFO_SIZE, neg->pool) == APR_SUCCESS) { + variant->bytes = statb.size; + } } } @@ -2060,7 +2061,7 @@ static void set_neg_headers(request_rec *r, negotiation_state *neg, char *lang; char *qstr; char *lenstr; - long len; + apr_off_t len; apr_array_header_t *arr; int max_vlist_array = (neg->avail_vars->nelts * 21); int first_variant = 1; @@ -2193,10 +2194,10 @@ static void set_neg_headers(request_rec *r, negotiation_state *neg, * content-length, which currently leads to the correct result). */ if (!(variant->sub_req && variant->sub_req->handler) - && (len = find_content_length(neg, variant)) != 0) { + && (len = find_content_length(neg, variant)) >= 0) { lenstr = (char *) apr_palloc(r->pool, 22); - apr_snprintf(lenstr, 22, "%ld", len); + apr_snprintf(lenstr, 22, "%" APR_OFF_T_FMT, len); *((const char **) apr_array_push(arr)) = " {length "; *((const char **) apr_array_push(arr)) = lenstr; *((const char **) apr_array_push(arr)) = "}"; -- 2.47.2