apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwool...@apache.org
Subject cvs commit: apr-util/buckets apr_buckets_pipe.c apr_buckets_socket.c
Date Tue, 27 Feb 2001 19:19:11 GMT
jwoolley    01/02/27 11:19:11

  Modified:    buckets  apr_buckets_pipe.c apr_buckets_socket.c
  Log:
  * pipe_read() and socket_read() must always allocate
    HUGE_STRING_LEN bytes, because they don't know
    ahead of time how much data they'll get back.  They
    should at least update the heap bucket's alloc_len
    to reflect the full length of the buffer.  (Issue
    #10 from "Bucket API cleanup issues" thread)
  
  * minor readability cleanups in pipe_read() and
    socket_read()
  
  Revision  Changes    Path
  1.31      +10 -6     apr-util/buckets/apr_buckets_pipe.c
  
  Index: apr_buckets_pipe.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_pipe.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -d -u -r1.30 -r1.31
  --- apr_buckets_pipe.c	2001/02/16 04:17:07	1.30
  +++ apr_buckets_pipe.c	2001/02/27 19:19:11	1.31
  @@ -60,7 +60,8 @@
   			      apr_size_t *len, apr_read_type_e block)
   {
       apr_file_t *p = a->data;
  -    apr_bucket *b;
  +    apr_bucket_shared *s;
  +    apr_bucket_heap *h;
       char *buf;
       apr_status_t rv;
       apr_interval_time_t timeout;
  @@ -70,9 +71,10 @@
           apr_file_pipe_timeout_set(p, 0);
       }
   
  -    buf = malloc(HUGE_STRING_LEN); /* XXX: check for failure? */
  -    *str = buf;
  +    *str = NULL;
       *len = HUGE_STRING_LEN;
  +    buf = malloc(*len); /* XXX: check for failure? */
  +
       rv = apr_file_read(p, buf, len);
   
       if (block == APR_NONBLOCK_READ) {
  @@ -80,7 +82,6 @@
       }
   
       if (rv != APR_SUCCESS && rv != APR_EOF) {
  -        *str = NULL;
   	free(buf);
           return rv;
       }
  @@ -89,6 +90,10 @@
        * even if we read nothing because we hit EOF.
        */
       apr_bucket_heap_make(a, buf, *len, 0, NULL);  /* XXX: check for failure? */
  +    s = a->data;
  +    h = s->data;
  +    h->alloc_len = HUGE_STRING_LEN; /* note the real buffer size */
  +    *str = buf;
       /*
        * If there's more to read we have to keep the rest of the pipe
        * for later.  Otherwise, we'll close the pipe.
  @@ -102,8 +107,7 @@
        * new bucket.
        */
       if (*len > 0) {
  -        b = apr_bucket_pipe_create(p);
  -	APR_BUCKET_INSERT_AFTER(a, b);
  +        APR_BUCKET_INSERT_AFTER(a, apr_bucket_pipe_create(p));
       }
       else if (rv == APR_EOF) {
           apr_file_close(p);
  
  
  
  1.20      +10 -6     apr-util/buckets/apr_buckets_socket.c
  
  Index: apr_buckets_socket.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_socket.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -d -u -r1.19 -r1.20
  --- apr_buckets_socket.c	2001/02/23 00:46:17	1.19
  +++ apr_buckets_socket.c	2001/02/27 19:19:11	1.20
  @@ -60,7 +60,8 @@
   			      apr_size_t *len, apr_read_type_e block)
   {
       apr_socket_t *p = a->data;
  -    apr_bucket *b;
  +    apr_bucket_shared *s;
  +    apr_bucket_heap *h;
       char *buf;
       apr_status_t rv;
       apr_int32_t timeout;
  @@ -70,9 +71,10 @@
           apr_setsocketopt(p, APR_SO_TIMEOUT, 0);
       }
   
  -    buf = malloc(HUGE_STRING_LEN); /* XXX: check for failure? */
  -    *str = buf;
  +    *str = NULL;
       *len = HUGE_STRING_LEN;
  +    buf = malloc(*len); /* XXX: check for failure? */
  +
       rv = apr_recv(p, buf, len);
   
       if (block == APR_NONBLOCK_READ) {
  @@ -80,7 +82,6 @@
       }
   
       if (rv != APR_SUCCESS && rv != APR_EOF) {
  -        *str = NULL;
   	free(buf);
           return rv;
       }
  @@ -89,6 +90,10 @@
        * even if we read nothing because we hit EOF.
        */
       apr_bucket_heap_make(a, buf, *len, 0, NULL);  /* XXX: check for failure? */
  +    s = a->data;
  +    h = s->data;
  +    h->alloc_len = HUGE_STRING_LEN; /* note the real buffer size */
  +    *str = buf;
       /*
        * If there's more to read we have to keep the rest of the socket
        * for later. XXX: Note that more complicated bucket types that
  @@ -105,8 +110,7 @@
        * down for reading, but there is no benefit to doing so.
        */
       if (*len > 0) {
  -        b = apr_bucket_socket_create(p);
  -	APR_BUCKET_INSERT_AFTER(a, b);
  +        APR_BUCKET_INSERT_AFTER(a, apr_bucket_socket_create(p));
       }
       else if (rv == APR_EOF && block == APR_NONBLOCK_READ) {
           return APR_EOF;
  
  
  

Mime
View raw message