httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@locus.apache.org
Subject cvs commit: apache-2.0/src/main http_protocol.c
Date Fri, 13 Oct 2000 18:39:23 GMT
trawick     00/10/13 11:39:21

  Modified:    src/include httpd.h
               src/main http_protocol.c
  Log:
  Introduce ap_debug_assert() macro, like ap_assert() but only active if
  AP_DEBUG is defined.
  
  ap_get_client_block():
  . avoid some cases where we leak a temporary bucket brigade
  . clean up/fix the logic to copy a brigade into the caller's buffer;
    the wrong length was used in some cases
  . add an AP_DEBUG-only assertion for some assumptions made regarding
    the brigade returned by the filters
  
  Submitted by:	partly by Greg Stein, but of course anything bad is mine
  
  Revision  Changes    Path
  1.101     +10 -0     apache-2.0/src/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/httpd.h,v
  retrieving revision 1.100
  retrieving revision 1.101
  diff -u -r1.100 -r1.101
  --- httpd.h	2000/10/12 19:45:56	1.100
  +++ httpd.h	2000/10/13 18:39:16	1.101
  @@ -1599,6 +1599,10 @@
   
   /*
    * Redefine assert() to something more useful for an Apache...
  + *
  + * Use ap_assert() if the condition should always be checked.
  + * Use ap_debug_assert() if the condition should only be checked when AP_DEBUG
  + * is defined.
    */
   /**
    * Log an assertion to the error log
  @@ -1610,6 +1614,12 @@
   API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine)
   			    __attribute__((noreturn));
   #define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))
  +
  +#ifdef AP_DEBUG
  +#define ap_debug_assert(exp) ap_assert(exp)
  +#else
  +#define ap_debug_assert(exp) ((void)0)
  +#endif
   
   /* A set of flags which indicate places where the server should raise(SIGSTOP).
    * This is useful for debugging, because you can then attach to that process
  
  
  
  1.169     +12 -15    apache-2.0/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v
  retrieving revision 1.168
  retrieving revision 1.169
  diff -u -r1.168 -r1.169
  --- http_protocol.c	2000/10/13 17:54:24	1.168
  +++ http_protocol.c	2000/10/13 18:39:18	1.169
  @@ -2396,7 +2396,7 @@
       apr_status_t rv;
       apr_int32_t timeout;
       ap_bucket *b, *old;
  -    ap_bucket_brigade *bb = ap_brigade_create(r->pool);
  +    ap_bucket_brigade *bb;
   
       if (!r->read_chunked) {     /* Content-length read */
           const char *tempbuf;
  @@ -2406,6 +2406,7 @@
           if (len_to_read == 0) {
               return 0;
           }
  +        bb = ap_brigade_create(r->pool);
           do {
               if (AP_BRIGADE_EMPTY(bb)) {
                   apr_getsocketopt(r->connection->client->bsock, APR_SO_TIMEOUT,
&timeout);
  @@ -2416,6 +2417,7 @@
                        */
                       apr_setsocketopt(r->connection->client->bsock, APR_SO_TIMEOUT,
timeout);
                       r->connection->keepalive = -1;
  +                    ap_brigade_destroy(bb);
                       return -1;
                   }
                   apr_setsocketopt(r->connection->client->bsock, APR_SO_TIMEOUT,
timeout);
  @@ -2433,19 +2435,14 @@
           total = 0;
           do {
               rv = ap_bucket_read(b, &tempbuf, &len_read, 0);
  -            if (len_to_read < b->length) { /* shouldn't happen */
  -                ap_bucket_split(b, len_to_read);
  -            }
  -            else {
  -                len_to_read = len_read;
  -            }
  -            
  -            memcpy(buffer, tempbuf, len_to_read);
  -            buffer += len_to_read;
  -            
  -            r->read_length += len_to_read;
  -            total += len_to_read;
  -            r->remaining -= len_to_read;
  +            ap_debug_assert(total + len_read <= bufsiz); /* because we told the filter

  +                                                          * below us not to give us too
much */
  +            ap_debug_assert(r->remaining >= len_read);
  +            memcpy(buffer, tempbuf, len_read);
  +            buffer += len_read;
  +            r->read_length += len_read;
  +            total += len_read;
  +            r->remaining -= len_read;
               old = b;
               b = AP_BUCKET_NEXT(b);
               AP_BUCKET_REMOVE(old);
  @@ -2454,7 +2451,7 @@
           ap_brigade_destroy(bb);
           return total;
       }
  -   
  +
       /*
        * Handle chunked reading Note: we are careful to shorten the input
        * bufsiz so that there will always be enough space for us to add a CRLF
  
  
  

Mime
View raw message