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/main http_core.c
Date Sat, 09 Sep 2000 01:11:15 GMT
fanf        00/09/08 18:11:15

  Modified:    src/ap   ap_buckets.c
               src/include ap_ring.h
               src/lib/apr/lib Makefile.in
               src/main http_core.c
  Log:
  Fix inserting elements at the head and tail of a ring when the ring is
  empty. Avoiding referring to the element type in the macros resulted
  in some double dereferences that did the wrong thing.
  Reported by:	Jeff Trawick
  
  Revision  Changes    Path
  1.14      +2 -2      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.13
  retrieving revision 1.14
  diff -u -u -r1.13 -r1.14
  --- ap_buckets.c	2000/09/08 10:15:57	1.13
  +++ ap_buckets.c	2000/09/09 01:11:13	1.14
  @@ -111,7 +111,7 @@
   API_EXPORT(void) ap_brigade_add_bucket(ap_bucket_brigade *b, 
   				       ap_bucket *e)
   {
  -    AP_RING_INSERT_TAIL(&b->list, e, link);
  +    AP_RING_INSERT_TAIL(&b->list, e, ap_bucket, link);
   }
   
   API_EXPORT(void) ap_brigade_catenate(ap_bucket_brigade *a, 
  @@ -128,7 +128,7 @@
       a = ap_brigade_create(b->p);
       f = AP_RING_LAST(&b->list);
       AP_RING_UNSPLICE(e, f, link);
  -    AP_RING_SPLICE_HEAD(&a->list, e, f, link);
  +    AP_RING_SPLICE_HEAD(&a->list, e, f, ap_bucket, link);
       return a;
   }
   
  
  
  
  1.4       +49 -14    apache-2.0/src/include/ap_ring.h
  
  Index: ap_ring.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/ap_ring.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -u -r1.3 -r1.4
  --- ap_ring.h	2000/09/08 02:44:21	1.3
  +++ ap_ring.h	2000/09/09 01:11:14	1.4
  @@ -175,22 +175,19 @@
   #define AP_RING_INSERT_AFTER(lep, nep, link)				\
   	AP_RING_SPLICE_AFTER((lep), (nep), (nep), link)
   
  -/*
  - * We could implement these by splicing after and before the sentinel
  - * instead of before the first and after the last respectively, but
  - * then the caller would have to pass in the element type.
  - */
  -#define AP_RING_SPLICE_HEAD(hp, ep1, epN, link)				\
  -	AP_RING_SPLICE_BEFORE(AP_RING_FIRST((hp)), (ep1), (epN), link)
  -
  -#define AP_RING_SPLICE_TAIL(hp, ep1, epN, link)				\
  -	AP_RING_SPLICE_AFTER(AP_RING_LAST((hp)), (ep1), (epN), link)
  +#define AP_RING_SPLICE_HEAD(hp, ep1, epN, elem, link)			\
  +	AP_RING_SPLICE_AFTER(AP_RING_SENTINEL((hp), elem, link),	\
  +			     (ep1), (epN), link)
  +
  +#define AP_RING_SPLICE_TAIL(hp, ep1, epN, elem, link)			\
  +	AP_RING_SPLICE_BEFORE(AP_RING_SENTINEL((hp), elem, link),	\
  +			     (ep1), (epN), link)
   
  -#define AP_RING_INSERT_HEAD(hp, nep, link)				\
  -	AP_RING_SPLICE_HEAD((hp), (nep), (nep), link)
  +#define AP_RING_INSERT_HEAD(hp, nep, elem, link)			\
  +	AP_RING_SPLICE_HEAD((hp), (nep), (nep), elem, link)
   
  -#define AP_RING_INSERT_TAIL(hp, nep, link)				\
  -	AP_RING_SPLICE_TAIL((hp), (nep), (nep), link)
  +#define AP_RING_INSERT_TAIL(hp, nep, elem, link)			\
  +	AP_RING_SPLICE_TAIL((hp), (nep), (nep), elem, link)
   
   /*
    * Concatenating ring h2 onto the end of ring h1 leaves h2 empty.
  @@ -232,5 +229,43 @@
       for ((ep)  = AP_RING_LAST((hp));					\
   	 (ep) != AP_RING_SENTINEL((hp), elem, link);			\
   	 (ep)  = AP_RING_PREV((ep), link))
  +
  +#ifdef AP_RING_DEBUG
  +#include <stdio.h>
  +#define AP_RING_CHECK_ONE(msg, ptr)					\
  +	fprintf(stderr, "*** %s %p\n", msg, ptr)
  +#define AP_RING_CHECK(hp, elem, link, msg)				\
  +	AP_RING_CHECK_ELEM(AP_RING_SENTINEL(hp, elem, link), elem, link, msg)
  +#define AP_RING_CHECK_ELEM(ep, elem, link, msg) do {			\
  +	struct elem *start = (ep);					\
  +	struct elem *this = start;					\
  +	fprintf(stderr, "*** ring check start -- %s\n", msg);		\
  +	do {								\
  +	    fprintf(stderr, "\telem %p\n", this);			\
  +	    fprintf(stderr, "\telem->next %p\n",			\
  +		    AP_RING_NEXT(this, link));				\
  +	    fprintf(stderr, "\telem->prev %p\n",			\
  +		    AP_RING_PREV(this, link));				\
  +	    fprintf(stderr, "\telem->next->prev %p\n",			\
  +		    AP_RING_PREV(AP_RING_NEXT(this, link), link));	\
  +	    fprintf(stderr, "\telem->prev->next %p\n",			\
  +		    AP_RING_NEXT(AP_RING_PREV(this, link), link));	\
  +	    if (AP_RING_PREV(AP_RING_NEXT(this, link), link) != this) {	\
  +		fprintf(stderr, "\t*** this->next->prev != this\n");	\
  +		break;							\
  +	    }								\
  +	    if (AP_RING_NEXT(AP_RING_PREV(this, link), link) != this) {	\
  +		fprintf(stderr, "\t*** this->prev->next != this\n");	\
  +		break;							\
  +	    }								\
  +	    this = AP_RING_NEXT(this, link);				\
  +	} while (this != start);					\
  +	fprintf(stderr, "*** ring check end\n");			\
  +    } while (0)
  +#else
  +#define AP_RING_CHECK_ONE(msg, ptr)
  +#define AP_RING_CHECK(hp, elem, link, msg)
  +#define AP_RING_CHECK_ELEM(ep, elem, link, msg)
  +#endif
   
   #endif /* !AP_RING_H */
  
  
  
  1.30      +5 -0      apache-2.0/src/lib/apr/lib/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/lib/Makefile.in,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -u -r1.29 -r1.30
  --- Makefile.in	2000/07/24 23:28:04	1.29
  +++ Makefile.in	2000/09/09 01:11:14	1.30
  @@ -58,3 +58,8 @@
    $(INCDIR)/apr_dso.h $(INCDIR)/apr_strings.h $(INCDIR)/apr_lib.h \
    $(INCDIR)/apr_pools.h $(INCDIR)/apr_tables.h ../misc/unix/misc.h \
    $(INCDIR)/apr_getopt.h
  +apr_signal.o: apr_signal.c $(INCDIR)/apr_private.h \
  + $(INCDIR)/apr_lib.h $(INCDIR)/apr.h $(INCDIR)/apr_pools.h \
  + $(INCDIR)/apr_thread_proc.h $(INCDIR)/apr_file_io.h \
  + $(INCDIR)/apr_general.h $(INCDIR)/apr_errno.h $(INCDIR)/apr_time.h \
  + $(INCDIR)/apr_tables.h
  
  
  
  1.114     +2 -2      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.113
  retrieving revision 1.114
  diff -u -u -r1.113 -r1.114
  --- http_core.c	2000/09/08 10:16:08	1.113
  +++ http_core.c	2000/09/09 01:11:15	1.114
  @@ -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, link);
  +    AP_RING_INSERT_HEAD(&b->list, e, ap_bucket, link);
       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);
       } else {
   	e = ap_bucket_create_immortal(CRLF, 2);
  -	AP_RING_INSERT_TAIL(&b->list, e, link);
  +	AP_RING_INSERT_TAIL(&b->list, e, ap_bucket, link);
       }
       return ap_pass_brigade(f->next, b);
   }
  
  
  

Mime
View raw message