[master] 9b216d2 Stringify boc_state
Federico G. Schwindt
fgsch at lodoss.net
Thu Jun 16 14:41:07 CEST 2016
commit 9b216d2e1cfb7d51debd79e38c9ce2bb54fed4a7
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Thu Jun 16 13:32:04 2016 +0100
Stringify boc_state
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index c1b90ae..8ee6f5a 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -360,12 +360,9 @@ struct storeobj {
* The macro-states we expose outside the fetch code
*/
enum boc_state_e {
- BOS_INVALID = 0, /* don't touch (yet) */
- BOS_REQ_DONE, /* beresp.* can be examined */
- BOS_PREP_STREAM, /* Prepare for streaming */
- BOS_STREAM, /* beresp.* can be examined */
- BOS_FINISHED, /* object is complete */
- BOS_FAILED, /* something went wrong */
+#define BOC_STATE(U, l) BOS_##U,
+#include "tbl/boc_state.h"
+#undef BOC_STATE
};
struct boc {
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index b3171f9..285c9ff 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -94,6 +94,20 @@ reqbody_status_2str(enum req_body_state_e e)
/*--------------------------------------------------------------------*/
+static const char *
+boc_state_2str(enum boc_state_e e)
+{
+ switch (e) {
+#define BOC_STATE(U,l) case BOS_##U: return(#l);
+#include "tbl/boc_state.h"
+#undef BOC_STATE
+ default:
+ return ("?");
+ }
+}
+
+/*--------------------------------------------------------------------*/
+
const char *
sess_close_2str(enum sess_close sc, int want_desc)
{
@@ -231,7 +245,7 @@ pan_boc(struct vsb *vsb, const struct boc *boc)
VSB_indent(vsb, 2);
PAN_CheckMagic(vsb, boc, BOC_MAGIC);
VSB_printf(vsb, "refcnt = %u,\n", boc->refcount);
- VSB_printf(vsb, "state = %d,\n", boc->state);
+ VSB_printf(vsb, "state = %s,\n", boc_state_2str(boc->state));
VSB_printf(vsb, "vary = %p,\n", boc->vary);
VSB_printf(vsb, "stevedore_priv = %p,\n", boc->stevedore_priv);
VSB_indent(vsb, -2);
diff --git a/include/tbl/boc_state.h b/include/tbl/boc_state.h
new file mode 100644
index 0000000..c3a2586
--- /dev/null
+++ b/include/tbl/boc_state.h
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2016 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Federico G. Schwindt <fgsch at lodoss.net>
+ *
+ * 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.
+ */
+
+/*lint -save -e525 -e539 */
+BOC_STATE(INVALID, invalid) /* don't touch (yet) */
+BOC_STATE(REQ_DONE, req_done) /* beresp.* can be examined */
+BOC_STATE(PREP_STREAM, prep_stream) /* Prepare for streaming */
+BOC_STATE(STREAM, stream) /* beresp.* can be examined */
+BOC_STATE(FINISHED, finished) /* object is complete */
+BOC_STATE(FAILED, failed) /* something went wrong */
+/*lint -restore */
More information about the varnish-commit
mailing list