[3.0] c8a05bf Add text representation to Fetch_Body VSL message.

Tollef Fog Heen tfheen at varnish-cache.org
Thu Sep 22 14:02:07 CEST 2011


commit c8a05bf6a74750d02955c2e857c687c2d76d0b7c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Sep 7 11:03:35 2011 +0000

    Add text representation to Fetch_Body VSL message.

diff --git a/bin/varnishd/body_status.h b/bin/varnishd/body_status.h
new file mode 100644
index 0000000..33803f9
--- /dev/null
+++ b/bin/varnishd/body_status.h
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2011 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Various ways to handle the body coming from the backend.
+ */
+
+/*lint -save -e525 -e539 */
+BODYSTATUS(NONE, none)
+BODYSTATUS(ZERO, zero)
+BODYSTATUS(ERROR, error)
+BODYSTATUS(CHUNKED, chunked)
+BODYSTATUS(LENGTH, length)
+BODYSTATUS(EOF, eof)
+/*lint -restore */
diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index f9989fb..09c94f3 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -66,14 +66,23 @@
 #include "vsl.h"
 
 enum body_status {
-	BS_NONE,
-	BS_ZERO,
-	BS_ERROR,
-	BS_CHUNKED,
-	BS_LENGTH,
-	BS_EOF
+#define BODYSTATUS(U,l)	BS_##U,
+#include "body_status.h"
+#undef BODYSTATUS
 };
 
+static inline const char *
+body_status(enum body_status e)
+{
+	switch(e) {
+#define BODYSTATUS(U,l)	case BS_##U: return (#l);
+#include "body_status.h"
+#undef BODYSTATUS
+	default:
+		return ("?");
+	}
+}
+
 /*
  * NB: HDR_STATUS is only used in cache_http.c, everybody else uses the
  * http->status integer field.
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index 657392f..24463f5 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -543,8 +543,9 @@ FetchBody(struct sess *sp)
 	 */
 	AZ(vfp_nop_end(sp));
 
-	WSL(sp->wrk, SLT_Fetch_Body, sp->vbc->fd, "%u %d %u",
-	    sp->wrk->body_status, cls, mklen);
+	WSL(sp->wrk, SLT_Fetch_Body, sp->vbc->fd, "%u(%s) %d %u",
+	    sp->wrk->body_status, body_status(sp->wrk->body_status),
+	    cls, mklen);
 
 	if (sp->wrk->body_status == BS_ERROR) {
 		VDI_CloseFd(sp);
diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt
index 1e88f1b..f2d2a6b 100644
--- a/bin/varnishd/flint.lnt
+++ b/bin/varnishd/flint.lnt
@@ -86,6 +86,7 @@
 -efile(451, "sys/\*.h")	// No include guard
 -efile(451, "machine/\*.h")	// No include guard
 -efile(451, "vcl_returns.h")	// No include guard
+-efile(451, "body_status.h")	// No include guard
 -efile(451, "locks.h")	// No include guard
 -efile(451, "cache_backend_poll.h")	// No include guard
 -efile(451, "steps.h")	// No include guard



More information about the varnish-commit mailing list