r5377 - trunk/varnish-cache/bin/varnishd

phk at varnish-cache.org phk at varnish-cache.org
Fri Oct 1 11:00:09 CEST 2010


Author: phk
Date: 2010-10-01 11:00:08 +0200 (Fri, 01 Oct 2010)
New Revision: 5377

Modified:
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
Unify/macroize handling of http->status fields



Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2010-10-01 08:50:43 UTC (rev 5376)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2010-10-01 09:00:08 UTC (rev 5377)
@@ -293,16 +293,30 @@
 
 /*--------------------------------------------------------------------*/
 
-/* XXX: review this */
+#define VRT_DO_STATUS(obj, http)				\
+void								\
+VRT_l_##obj##_status(const struct sess *sp, int num)		\
+{								\
+								\
+	assert(num >= 100 && num <= 999);			\
+	http->status = num;					\
+}								\
+								\
+int								\
+VRT_r_##obj##_status(const struct sess *sp)			\
+{								\
+								\
+	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
+	return(http->status);					\
+}
 
-void
-VRT_l_obj_status(const struct sess *sp, int num)
-{
+VRT_DO_STATUS(obj, sp->obj->http);
+VRT_DO_STATUS(beresp, sp->wrk->beresp);
+VRT_DO_STATUS(resp, sp->wrk->resp);
 
-	assert(num >= 100 && num <= 999);
-	sp->obj->http->status = num;
-}
+/*--------------------------------------------------------------------*/
 
+/* XXX: review this */
 /* Add an objecthead to the saintmode list for the (hopefully) relevant
  * backend. Some double-up asserting here to avoid assert-errors when there
  * is no object.
@@ -356,33 +370,6 @@
 
 	Lck_Unlock(&sp->vbc->backend->mtx);
 }
-
-int
-VRT_r_obj_status(const struct sess *sp)
-{
-
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
-	return (sp->obj->http->status);
-}
-
-void
-VRT_l_resp_status(const struct sess *sp, int num)
-{
-
-	assert(num >= 100 && num <= 999);
-	sp->wrk->resp->status = num;
-}
-
-int
-VRT_r_resp_status(const struct sess *sp)
-{
-
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->wrk->resp, HTTP_MAGIC);
-	return (sp->wrk->resp->status);
-}
-
 /*--------------------------------------------------------------------*/
 
 #define VBERESP(dir, type, onm, field)					\
@@ -463,22 +450,7 @@
 	return (sp->wrk->ttl - sp->t_req);
 }
 
-void
-VRT_l_beresp_status(const struct sess *sp, int num)
-{
 
-	assert(num >= 100 && num <= 999);
-	sp->wrk->beresp->status = num;
-}
-
-int
-VRT_r_beresp_status(const struct sess *sp)
-{
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	return (sp->wrk->beresp->status);
-}
-
-
 void
 VRT_l_bereq_connect_timeout(struct sess *sp, double num)
 {




More information about the varnish-commit mailing list