]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Change the length of the content args to apr_off_t identifiers, and fix
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 26 Jul 2001 15:53:15 +0000 (15:53 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 26 Jul 2001 15:53:15 +0000 (15:53 +0000)
  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
include/httpd.h
include/scoreboard.h
modules/http/http_protocol.c
modules/loggers/mod_log_config.c
modules/mappers/mod_negotiation.c

index 10250e04e0674e352a3d5b33b6cfba8edd9e1a5d..1d7a26a6ba1850d5f298c285ab33b0085c911fbd 100644 (file)
@@ -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
index 3220d9938eee1d63fbcc6fa578b4fdb3fae357a3..c2eba3bc8fbb26c98afbb337e0c39ca1d7d8d01e 100644 (file)
@@ -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 */
index d521a93747b4eabbda882e61c1d9ae0d206d010a..2f6c32c9f82b633172bb3b8835bf1e5f4ddfdc72 100644 (file)
@@ -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;
index 4e1be8ce42e53b7668e6792dba05a1ea8567ed31..b8f4b03da5eaf8ca52683543d838119fbf9154bf 100644 (file)
@@ -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;
index c42fdb03c6ab210d1f273e65037e555f50f425bd..a1ffcc5c69459cfd296195d884eb36633d8db6d2 100644 (file)
@@ -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);
     }
 }
 
index 4e56648a69407e6d2a206d8956cad941da5c1899..8773a874df01fe8b33864280f9661ef068689fac 100644 (file)
@@ -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)) = "}";