r4851 - in trunk/varnish-cache: include lib/libvarnishapi

phk at varnish-cache.org phk at varnish-cache.org
Fri May 21 13:11:50 CEST 2010


Author: phk
Date: 2010-05-21 13:11:50 +0200 (Fri, 21 May 2010)
New Revision: 4851

Modified:
   trunk/varnish-cache/include/varnishapi.h
   trunk/varnish-cache/lib/libvarnishapi/vsl.c
Log:
Make iterator deal correctly with end of list.



Modified: trunk/varnish-cache/include/varnishapi.h
===================================================================
--- trunk/varnish-cache/include/varnishapi.h	2010-05-21 11:11:13 UTC (rev 4850)
+++ trunk/varnish-cache/include/varnishapi.h	2010-05-21 11:11:50 UTC (rev 4851)
@@ -66,7 +66,7 @@
     const char *ident, unsigned *lenp);
 
 struct shmalloc *vsl_iter0(struct VSL_data *vd);
-struct shmalloc *vsl_itern(struct VSL_data *vd, struct shmalloc **pp);
+void vsl_itern(struct VSL_data *vd, struct shmalloc **pp);
 
 #define VSL_FOREACH(var, vd) \
 	for((var) = vsl_iter0((vd)); (var) != NULL; vsl_itern((vd), &(var)))

Modified: trunk/varnish-cache/lib/libvarnishapi/vsl.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsl.c	2010-05-21 11:11:13 UTC (rev 4850)
+++ trunk/varnish-cache/lib/libvarnishapi/vsl.c	2010-05-21 11:11:50 UTC (rev 4851)
@@ -177,19 +177,22 @@
 	return (&vd->vsl_lh->head);
 }
 
-struct shmalloc *
+void
 vsl_itern(struct VSL_data *vd, struct shmalloc **pp)
 {
 
 	CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
-	if (vd->alloc_seq != vd->vsl_lh->alloc_seq)
-		return(NULL);
+	if (vd->alloc_seq != vd->vsl_lh->alloc_seq) {
+		*pp = NULL;
+		return;
+	}
 	CHECK_OBJ_NOTNULL(*pp, SHMALLOC_MAGIC);
 	*pp = SHA_NEXT(*pp);
-	if ((void*)*pp >= vd->vsl_end)
-		return (NULL);
+	if ((void*)(*pp) >= vd->vsl_end) {
+		*pp = NULL;
+		return;
+	}
 	CHECK_OBJ_NOTNULL(*pp, SHMALLOC_MAGIC);
-	return (*pp);
 }
 
 /*--------------------------------------------------------------------*/




More information about the varnish-commit mailing list