httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@locus.apache.org
Subject cvs commit: apache-2.0/src/modules/standard mod_cgi.c
Date Sat, 09 Sep 2000 06:48:10 GMT
fanf        00/09/08 23:48:10

  Modified:    src/ap   ap_buckets.c ap_buckets_pipe.c
                        ap_buckets_refcount.c ap_buckets_simple.c
               src/include ap_buckets.h
               src/main http_core.c http_protocol.c util_filter.c
               src/modules/standard mod_cgi.c
  Log:
  Use wrapper macros to avoid the verbosity of the AP_RING macros when
  doing things with bucket brigades.
  
  Revision  Changes    Path
  1.15      +6 -18     apache-2.0/src/ap/ap_buckets.c
  
  Index: ap_buckets.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -u -r1.14 -r1.15
  --- ap_buckets.c	2000/09/09 01:11:13	1.14
  +++ ap_buckets.c	2000/09/09 06:48:07	1.15
  @@ -80,9 +80,9 @@
        * Bah! We can't use AP_RING_FOREACH here because this bucket has
        * gone away when we dig inside it to get the next one.
        */
  -    while (!AP_RING_EMPTY(&b->list, ap_bucket, link)) {
  -	e = AP_RING_FIRST(&b->list);
  -	AP_RING_REMOVE(e, link);
  +    while (!AP_BRIGADE_EMPTY(b)) {
  +	e = AP_BRIGADE_FIRST(b);
  +	AP_BUCKET_REMOVE(e);
   	ap_bucket_destroy(e);
       }
       /*
  @@ -108,18 +108,6 @@
       return b;
   }
   
  -API_EXPORT(void) ap_brigade_add_bucket(ap_bucket_brigade *b, 
  -				       ap_bucket *e)
  -{
  -    AP_RING_INSERT_TAIL(&b->list, e, ap_bucket, link);
  -}
  -
  -API_EXPORT(void) ap_brigade_catenate(ap_bucket_brigade *a, 
  -				     ap_bucket_brigade *b)
  -{
  -    AP_RING_CONCAT(&a->list, &b->list, ap_bucket, link);
  -}
  -
   API_EXPORT(ap_bucket_brigade *) ap_brigade_split(ap_bucket_brigade *b,
   						 ap_bucket *e)
   {
  @@ -139,7 +127,7 @@
       struct iovec *orig;
   
       orig = vec;
  -    AP_RING_FOREACH(e, &b->list, ap_bucket, link) {
  +    AP_BRIGADE_FOREACH(e, b) {
   	if (nvec-- == 0)
               break;
   	e->read(e, (const char **)&vec->iov_base, &vec->iov_len, 0);
  @@ -169,7 +157,7 @@
           }
           k += i;
   
  -        ap_brigade_add_bucket(b, r);
  +        AP_BRIGADE_INSERT_TAIL(b, r);
       }
   
       return k;
  @@ -198,7 +186,7 @@
       res = apr_vsnprintf(buf, 4096, fmt, va);
   
       r = ap_bucket_create_heap(buf, strlen(buf), 1, NULL);
  -    ap_brigade_add_bucket(b, r);
  +    AP_BRIGADE_INSERT_TAIL(b, r);
   
       return res;
   }
  
  
  
  1.9       +8 -8      apache-2.0/src/ap/ap_buckets_pipe.c
  
  Index: ap_buckets_pipe.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_pipe.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -u -r1.8 -r1.9
  --- ap_buckets_pipe.c	2000/09/08 22:23:09	1.8
  +++ ap_buckets_pipe.c	2000/09/09 06:48:07	1.9
  @@ -67,11 +67,11 @@
   }
   
   /* Ignore the block arg for now.  We can fix that tomorrow. */
  -static apr_status_t pipe_read(ap_bucket *b, const char **str,
  -				apr_ssize_t *len, int block)
  +static apr_status_t pipe_read(ap_bucket *a, const char **str,
  +			      apr_ssize_t *len, int block)
   {
  -    ap_bucket_pipe *bd = b->data;
  -    ap_bucket *a;
  +    ap_bucket_pipe *d = a->data;
  +    ap_bucket *b;
       char *buf;
       apr_status_t rv;
   
  @@ -81,14 +81,14 @@
       buf = malloc(IOBUFSIZE);
       *str = buf;
       *len = IOBUFSIZE;
  -    if ((rv = apr_read(bd->thepipe, buf, len)) != APR_SUCCESS) {
  +    if ((rv = apr_read(d->thepipe, buf, len)) != APR_SUCCESS) {
   	free(buf);
           return rv;
       }
       if (*len > 0) {
  -        a = ap_bucket_create_pipe(bd->thepipe);
  -        b = ap_bucket_make_heap(b, buf, *len, 0, NULL);
  -	AP_RING_INSERT_AFTER(b, a, link);
  +        b = ap_bucket_create_pipe(d->thepipe);
  +        a = ap_bucket_make_heap(a, buf, *len, 0, NULL);
  +	AP_BUCKET_INSERT_AFTER(a, b);
       }
       return APR_SUCCESS;
   }
  
  
  
  1.5       +1 -1      apache-2.0/src/ap/ap_buckets_refcount.c
  
  Index: ap_buckets_refcount.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_refcount.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -u -r1.4 -r1.5
  --- ap_buckets_refcount.c	2000/09/08 10:15:58	1.4
  +++ ap_buckets_refcount.c	2000/09/09 06:48:07	1.5
  @@ -90,7 +90,7 @@
       b->length -= point;
       bd->start += point;
   
  -    AP_RING_INSERT_AFTER(a, b, link);
  +    AP_BUCKET_INSERT_AFTER(a, b);
   
       return APR_SUCCESS;
   }
  
  
  
  1.4       +1 -1      apache-2.0/src/ap/ap_buckets_simple.c
  
  Index: ap_buckets_simple.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_simple.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -u -r1.3 -r1.4
  --- ap_buckets_simple.c	2000/09/08 10:15:59	1.3
  +++ ap_buckets_simple.c	2000/09/09 06:48:07	1.4
  @@ -89,7 +89,7 @@
       b->length -= point;
       bd->start += point;
   
  -    AP_RING_INSERT_AFTER(a, b, link);
  +    AP_BUCKET_INSERT_AFTER(a, b);
   
       return APR_SUCCESS;
   }
  
  
  
  1.25      +34 -23    apache-2.0/src/include/ap_buckets.h
  
  Index: ap_buckets.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/ap_buckets.h,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -u -r1.24 -r1.25
  --- ap_buckets.h	2000/09/09 06:01:24	1.24
  +++ ap_buckets.h	2000/09/09 06:48:08	1.25
  @@ -226,6 +226,39 @@
   };
   
   /**
  + * Wrappers around the RING macros to reduce the verbosity of the code
  + * that handles bucket brigades.
  + */
  +#define AP_BRIGADE_SENTINEL(b)	AP_RING_SENTINEL(&(b)->list, ap_bucket, link)
  +
  +#define AP_BRIGADE_EMPTY(b)	AP_RING_EMPTY(&(b)->list, ap_bucket, link)
  +
  +#define AP_BRIGADE_FIRST(b)	AP_RING_FIRST(&(b)->list)
  +#define AP_BRIGADE_LAST(b)	AP_RING_LAST(&(b)->list)
  +
  +#define AP_BRIGADE_FOREACH(e, b)					\
  +	AP_RING_FOREACH((e), &(b)->list, ap_bucket, link)
  +
  +#define AP_BRIGADE_INSERT_HEAD(b, e)					\
  +	AP_RING_INSERT_HEAD(&(b)->list, (e), ap_bucket, link)
  +#define AP_BRIGADE_INSERT_TAIL(b, e)					\
  +	AP_RING_INSERT_TAIL(&(b)->list, (e), ap_bucket, link)
  +
  +#define AP_BRIGADE_CONCAT(a, b)						\
  +	AP_RING_CONCAT(&(a)->list, &(b)->list, ap_bucket, link)
  +
  +#define AP_BUCKET_INSERT_BEFORE(a, b)					\
  +	AP_RING_INSERT_BEFORE((a), (b), link)
  +#define AP_BUCKET_INSERT_AFTER(a, b)					\
  +	AP_RING_INSERT_AFTER((a), (b), link)
  +
  +#define AP_BUCKET_NEXT(e)	AP_RING_NEXT((e), link)
  +#define AP_BUCKET_PREV(e)	AP_RING_PREV((e), link)
  +
  +#define AP_BUCKET_REMOVE(e)	AP_RING_REMOVE((e), link)
  +
  +
  +/**
    * General-purpose reference counting for the varous bucket types.
    *
    * Any bucket type that keeps track of the resources it uses (i.e.
  @@ -233,8 +266,7 @@
    * attach a reference count to the resource so that it can be freed
    * when the last bucket that uses it goes away. Resource-sharing may
    * occur because of bucket splits or buckets that refer to globally
  - * cached data.
  - */
  + * cached data. */
   
   /**
    * The structure used to manage the shared resource must start with an
  @@ -345,27 +377,6 @@
    * @deffunc apr_status_t ap_brigade_destroy(ap_bucket_brigade *b)
    */
   API_EXPORT(apr_status_t) ap_brigade_destroy(ap_bucket_brigade *b);
  -
  -/**
  - * add a bucket to the end of a bucket_brigade.
  - * @param b The bucket brigade to add the bucket to
  - * @param e The bucket list to add
  - * @deffunc void ap_brigade_append_buckets(ap_bucket_brigade *b, ap_bucket *e)
  - */
  -API_EXPORT(void) ap_brigade_add_bucket(ap_bucket_brigade *b,
  -				       ap_bucket *e);
  -
  -/**
  - * Concatenate bucket_brigade b onto the end of bucket_brigade a,
  - * emptying bucket_brigade b in the process. Neither bucket brigade
  - * can be NULL, but either one of them can be emtpy when calling this
  - * function.
  - * @param a The brigade to catenate to.
  - * @param b The brigade to add to a.  This brigade will be empty on return
  - * @deffunc void ap_brigade_catenate(ap_bucket_brigade *a, ap_bucket_brigade *b)
  - */
  -API_EXPORT(void) ap_brigade_catenate(ap_bucket_brigade *a, 
  -				     ap_bucket_brigade *b);
   
   /**
    * Split a bucket brigade into two, such that the given bucket is the
  
  
  
  1.115     +6 -6      apache-2.0/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_core.c,v
  retrieving revision 1.114
  retrieving revision 1.115
  diff -u -u -r1.114 -r1.115
  --- http_core.c	2000/09/09 01:11:15	1.114
  +++ http_core.c	2000/09/09 06:48:09	1.115
  @@ -2930,14 +2930,14 @@
       }
       hdr_len = apr_snprintf(chunk_hdr, sizeof(chunk_hdr), "%qx" CRLF, bytes);
       e = ap_bucket_create_transient(chunk_hdr, hdr_len);
  -    AP_RING_INSERT_HEAD(&b->list, e, ap_bucket, link);
  +    AP_BRIGADE_INSERT_HEAD(b, e);
       if (eos) {
   	/* any trailer should go between the last two CRLFs */
   	e = ap_bucket_create_immortal(CRLF "0" CRLF CRLF, 7);
  -	AP_RING_INSERT_BEFORE(AP_RING_LAST(&b->list), e, link);
  +	AP_BUCKET_INSERT_BEFORE(AP_BRIGADE_LAST(b), e);
       } else {
   	e = ap_bucket_create_immortal(CRLF, 2);
  -	AP_RING_INSERT_TAIL(&b->list, e, ap_bucket, link);
  +	AP_BRIGADE_INSERT_TAIL(b, e);
       }
       return ap_pass_brigade(f->next, b);
   }
  @@ -2954,7 +2954,7 @@
       for (more = NULL; b; b = more, more = NULL) {
   	apr_off_t bytes = 0;
   	int eos = 0;
  -	AP_RING_FOREACH(e, &b->list, ap_bucket, link) {
  +	AP_BRIGADE_FOREACH(e, b) {
   	    if (e->type == AP_BUCKET_EOS) {
   		/* assume it is the last one in the brigade */
   		eos = 1;
  @@ -2968,7 +2968,7 @@
   		    return rv;
   		}
   		bytes += len;
  -		more = ap_brigade_split(b, AP_RING_NEXT(e, link));
  +		more = ap_brigade_split(b, AP_BUCKET_NEXT(e));
   		break;
   	    }
   	    else {
  @@ -3030,7 +3030,7 @@
       } 
       else {
   #endif
  -    AP_RING_FOREACH(e, &b->list, ap_bucket, link) {
  +    AP_BRIGADE_FOREACH(e, b) {
   	rv = e->read(e, &str, &len, 0);
   	if (rv != APR_SUCCESS) {
               return rv;
  
  
  
  1.120     +16 -6     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.119
  retrieving revision 1.120
  diff -u -u -r1.119 -r1.120
  --- http_protocol.c	2000/09/08 10:16:09	1.119
  +++ http_protocol.c	2000/09/09 06:48:09	1.120
  @@ -1327,9 +1327,11 @@
   static void end_output_stream(request_rec *r)
   {
       ap_bucket_brigade *bb;
  +    ap_bucket *b;
   
       bb = ap_brigade_create(r->pool);
  -    ap_brigade_add_bucket(bb, ap_bucket_create_eos());
  +    b = ap_bucket_create_eos();
  +    AP_BRIGADE_INSERT_TAIL(bb, b);
       ap_pass_brigade(r->filters, bb);
   }
   
  @@ -2513,13 +2515,15 @@
                                size_t length)
   {
       ap_bucket_brigade *bb = NULL;
  -    
  +    ap_bucket *b;
  +
       /* WE probably need to do something to make sure we are respecting the
        * offset and length.  I think I know how to do this, but I will wait
        * until after the commit to actually write the code.
        */
       bb = ap_brigade_create(r->pool);
  -    ap_brigade_add_bucket(bb, ap_bucket_create_mmap(mm, 0, mm->size));
  +    b = ap_bucket_create_mmap(mm, 0, mm->size);
  +    AP_BRIGADE_INSERT_TAIL(bb, b);
       ap_pass_brigade(r->filters, bb);
   
       return mm->size; /* XXX - change API to report apr_status_t? */
  @@ -2529,13 +2533,15 @@
   API_EXPORT(int) ap_rputc(int c, request_rec *r)
   {
       ap_bucket_brigade *bb = NULL;
  +    ap_bucket *b;
       char c2 = (char)c;
   
       if (r->connection->aborted)
           return EOF;
   
       bb = ap_brigade_create(r->pool);
  -    ap_brigade_add_bucket(bb, ap_bucket_create_transient(&c2, 1)); 
  +    b = ap_bucket_create_transient(&c2, 1);
  +    AP_BRIGADE_INSERT_TAIL(bb, b);
       ap_pass_brigade(r->filters, bb);
   
       return c;
  @@ -2544,6 +2550,7 @@
   API_EXPORT(int) ap_rputs(const char *str, request_rec *r)
   {
       ap_bucket_brigade *bb = NULL;
  +    ap_bucket *b;
       apr_size_t len;
   
       if (r->connection->aborted)
  @@ -2553,7 +2560,8 @@
   
       len = strlen(str);
       bb = ap_brigade_create(r->pool);
  -    ap_brigade_add_bucket(bb, ap_bucket_create_transient(str, len));
  +    b = ap_bucket_create_transient(str, len);
  +    AP_BRIGADE_INSERT_TAIL(bb, b);
       ap_pass_brigade(r->filters, bb);
   
       return len;
  @@ -2562,6 +2570,7 @@
   API_EXPORT(int) ap_rwrite(const void *buf, int nbyte, request_rec *r)
   {
       ap_bucket_brigade *bb = NULL;
  +    ap_bucket *b;
   
       if (r->connection->aborted)
           return EOF;
  @@ -2569,7 +2578,8 @@
           return 0;
   
       bb = ap_brigade_create(r->pool);
  -    ap_brigade_add_bucket(bb, ap_bucket_create_transient(buf, nbyte)); 
  +    b = ap_bucket_create_transient(buf, nbyte);
  +    AP_BRIGADE_INSERT_TAIL(bb, b);
       ap_pass_brigade(r->filters, bb);
       return nbyte;
   }
  
  
  
  1.14      +2 -2      apache-2.0/src/main/util_filter.c
  
  Index: util_filter.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/util_filter.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -u -r1.13 -r1.14
  --- util_filter.c	2000/09/08 10:16:10	1.13
  +++ util_filter.c	2000/09/09 06:48:09	1.14
  @@ -175,7 +175,7 @@
       /* join the two brigades together.  *b is now empty so we can 
        * safely destroy it. 
        */
  -    ap_brigade_catenate(bb, *b);
  +    AP_BRIGADE_CONCAT(bb, *b);
       ap_brigade_destroy(*b);
       /* clear out the filter's context pointer.  If we don't do this, then
        * when we save more data to the filter, we will be appended to what is
  @@ -201,6 +201,6 @@
       AP_RING_FOREACH(e, &bb->list, ap_bucket, link) {
   	e->setaside(e);
       }
  -    ap_brigade_catenate(bb, *b);
  +    AP_BRIGADE_CONCAT(bb, *b);
       f->ctx = bb;
   }
  
  
  
  1.62      +11 -6     apache-2.0/src/modules/standard/mod_cgi.c
  
  Index: mod_cgi.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_cgi.c,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -u -r1.61 -r1.62
  --- mod_cgi.c	2000/09/08 10:16:14	1.61
  +++ mod_cgi.c	2000/09/09 06:48:10	1.62
  @@ -485,7 +485,8 @@
       char **argv = NULL;
   
       apr_file_t *script_out = NULL, *script_in = NULL, *script_err = NULL;
  -    ap_bucket_brigade *bb = NULL;
  +    ap_bucket_brigade *bb;
  +    ap_bucket *b;
       char argsbuffer[HUGE_STRING_LEN];
       int is_included = !strcmp(r->protocol, "INCLUDED");
       void *sconf = r->server->module_config;
  @@ -656,10 +657,12 @@
   	ap_send_http_header(r);
   	if (!r->header_only) {
               bb = ap_brigade_create(r->pool);
  -            ap_brigade_add_bucket(bb, ap_bucket_create_pipe(script_in));
  -            ap_brigade_add_bucket(bb, ap_bucket_create_eos());
  +	    b = ap_bucket_create_pipe(script_in);
  +	    AP_BRIGADE_INSERT_TAIL(bb, b);
  +            b = ap_bucket_create_eos();
  +	    AP_BRIGADE_INSERT_TAIL(bb, b);
  +	    ap_pass_brigade(r->filters, bb);
   	}
  -        ap_pass_brigade(r->filters, bb);
   
           log_script_err(r, script_err);
   	apr_close(script_err);
  @@ -667,8 +670,10 @@
   
       if (script_in && nph) {
           bb = ap_brigade_create(r->pool);
  -        ap_brigade_add_bucket(bb, ap_bucket_create_pipe(script_in));
  -        ap_brigade_add_bucket(bb, ap_bucket_create_eos());
  +	b = ap_bucket_create_pipe(script_in);
  +	AP_BRIGADE_INSERT_TAIL(bb, b);
  +	b = ap_bucket_create_eos();
  +	AP_BRIGADE_INSERT_TAIL(bb, b);
           ap_pass_brigade(r->filters, bb);
       }
   
  
  
  

Mime
View raw message