[master] 0cbab46 session close reason accounting
Nils Goroll
nils.goroll at uplex.de
Mon Mar 16 18:39:27 CET 2015
commit 0cbab464ab6479de2b2d686f562bc87064f15706
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Mon Mar 16 18:29:00 2015 +0100
session close reason accounting
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 6c46bea..0406d9e 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -86,7 +86,7 @@ enum req_body_state_e {
enum sess_close {
SC_NULL = 0,
-#define SESS_CLOSE(nm, stat, desc) SC_##nm,
+#define SESS_CLOSE(nm, stat, err, desc) SC_##nm,
#include "tbl/sess_close.h"
#undef SESS_CLOSE
};
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index f0c459d..1d2aa71 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -101,7 +101,8 @@ sess_close_2str(enum sess_close sc, int want_desc)
{
switch (sc) {
case SC_NULL: return(want_desc ? "(null)": "NULL");
-#define SESS_CLOSE(nm, s, desc) case SC_##nm: return(want_desc ? desc : #nm);
+#define SESS_CLOSE(nm, s, err, desc) \
+ case SC_##nm: return(want_desc ? desc : #nm);
#include "tbl/sess_close.h"
#undef SESS_CLOSE
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index f6868e8..9e27b03 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -305,6 +305,30 @@ SES_Wait(struct sess *sp)
}
/*--------------------------------------------------------------------
+ * Update sc_ counters by reason
+ *
+ * assuming that the approximation of non-atomic global counters is sufficient.
+ * if not: update to per-wrk
+ */
+static void
+ses_close_acct(enum sess_close reason)
+{
+ assert(reason != SC_NULL);
+ switch (reason) {
+#define SESS_CLOSE(reason, stat, err, desc) \
+ case SC_ ## reason: \
+ VSC_C_main->sc_ ## stat++; \
+ if (err) \
+ VSC_C_main->sess_closed_err++; \
+ break;
+#include "tbl/sess_close.h"
+#undef SESS_CLOSE
+ default:
+ WRONG("Wrong event in ses_close_acct");
+ }
+}
+
+/*--------------------------------------------------------------------
* Close a sessions connection.
* XXX: Technically speaking we should catch a t_end timestamp here
* XXX: for SES_Delete() to use.
@@ -320,6 +344,8 @@ SES_Close(struct sess *sp, enum sess_close reason)
i = close(sp->fd);
assert(i == 0 || errno != EBADF); /* XXX EINVAL seen */
sp->fd = -1;
+ if (reason != SC_NULL)
+ ses_close_acct(reason);
}
/*--------------------------------------------------------------------
diff --git a/include/tbl/sess_close.h b/include/tbl/sess_close.h
index f6e928d..21c78ab 100644
--- a/include/tbl/sess_close.h
+++ b/include/tbl/sess_close.h
@@ -29,20 +29,20 @@
/*lint -save -e525 -e539 */
-// enum sess_close SC.* stat Verbose error
-SESS_CLOSE(REM_CLOSE, rem_close, "Client Closed")
-SESS_CLOSE(REQ_CLOSE, req_close, "Client requested close")
-SESS_CLOSE(REQ_HTTP10, req_http10, "Proto < HTTP/1.1")
-SESS_CLOSE(RX_BAD, rx_bad, "Received bad req/resp")
-SESS_CLOSE(RX_BODY, rx_body, "Failure receiving req.body")
-SESS_CLOSE(RX_JUNK, rx_junk, "Received junk data")
-SESS_CLOSE(RX_OVERFLOW, rx_overflow, "Received buffer overflow")
-SESS_CLOSE(RX_TIMEOUT, rx_timeout, "Receive timeout")
-SESS_CLOSE(TX_PIPE, tx_pipe, "Piped transaction")
-SESS_CLOSE(TX_ERROR, tx_error, "Error transaction")
-SESS_CLOSE(TX_EOF, tx_eof, "EOF transmission")
-SESS_CLOSE(RESP_CLOSE, resp_close, "Backend/VCL requested close")
-SESS_CLOSE(OVERLOAD, overload, "Out of some resource")
-SESS_CLOSE(PIPE_OVERFLOW, pipe_overflow, "Session pipe overflow")
+// enum sess_close sc_* stat is_err Description
+SESS_CLOSE(REM_CLOSE, rem_close, 0, "Client Closed")
+SESS_CLOSE(REQ_CLOSE, req_close, 0, "Client requested close")
+SESS_CLOSE(REQ_HTTP10, req_http10, 1, "Proto < HTTP/1.1")
+SESS_CLOSE(RX_BAD, rx_bad, 1, "Received bad req/resp")
+SESS_CLOSE(RX_BODY, rx_body, 1, "Failure receiving req.body")
+SESS_CLOSE(RX_JUNK, rx_junk, 1, "Received junk data")
+SESS_CLOSE(RX_OVERFLOW, rx_overflow, 1, "Received buffer overflow")
+SESS_CLOSE(RX_TIMEOUT, rx_timeout, 1, "Receive timeout")
+SESS_CLOSE(TX_PIPE, tx_pipe, 0, "Piped transaction")
+SESS_CLOSE(TX_ERROR, tx_error, 1, "Error transaction")
+SESS_CLOSE(TX_EOF, tx_eof, 0, "EOF transmission")
+SESS_CLOSE(RESP_CLOSE, resp_close, 0, "Backend/VCL requested close")
+SESS_CLOSE(OVERLOAD, overload, 1, "Out of some resource")
+SESS_CLOSE(PIPE_OVERFLOW, pipe_overflow,1, "Session pipe overflow")
/*lint -restore */
diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h
index 94444d3..51ddb4f 100644
--- a/include/tbl/vsc_f_main.h
+++ b/include/tbl/vsc_f_main.h
@@ -388,6 +388,11 @@ VSC_F(sess_closed, uint64_t, 1, 'c', 'i', info,
"Session Closed",
""
)
+VSC_F(sess_closed_err, uint64_t, 0, 'c', 'i', info,
+ "Session Closed with error",
+ "Total number of sessions closed with errors."
+ " See sc_* diag counters for detailed breakdown"
+)
VSC_F(sess_pipeline, uint64_t, 1, 'c', 'i', info,
"Session Pipeline",
""
@@ -401,6 +406,23 @@ VSC_F(sess_herd, uint64_t, 1, 'c', 'i', diag,
""
)
+#define SESS_CLOSE_ERR0 "OK "
+#define SESS_CLOSE_ERR1 "Err "
+#define SESS_CLOSE_ERROR0 ""
+#define SESS_CLOSE_ERROR1 "Error "
+#define SESS_CLOSE(r, f, e, s) \
+VSC_F(sc_ ## f, uint64_t, 0, 'c', 'i', diag, \
+ "Session " SESS_CLOSE_ERR ## e #r, \
+ "Number of session closes with " \
+ SESS_CLOSE_ERROR ## e #r " (" s ")" \
+)
+#include "tbl/sess_close.h"
+#undef SESS_CLOSE
+#undef SESS_CLOSE_ERROR1
+#undef SESS_CLOSE_ERROR0
+#undef SESS_CLOSE_ERR1
+#undef SESS_CLOSE_ERR0
+
/*--------------------------------------------------------------------*/
VSC_F(shm_records, uint64_t, 0, 'c', 'i', diag,
diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h
index 0f9a56b..7af249f 100644
--- a/include/tbl/vsl_tags.h
+++ b/include/tbl/vsl_tags.h
@@ -81,7 +81,7 @@ SLTM(SessOpen, 0, "Client connection opened",
* XXX: in the middle of a macro invocation :-(
* XXX: If we could, these three lines would have described the
* XXX: 'reason' field below.
-#define SESS_CLOSE(nm, s, desc) " " #nm "\n\t" desc "\n\n"
+#define SESS_CLOSE(nm, s, err, desc) " " #nm "\n\t" desc "\n\n"
#include "tbl/sess_close.h"
#undef SESS_CLOSE
*/
More information about the varnish-commit
mailing list