Commit 0cbab464 authored by Nils Goroll's avatar Nils Goroll

session close reason accounting

parent 8457ac6e
......@@ -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
};
......
......@@ -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
......
......@@ -304,6 +304,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
......@@ -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);
}
/*--------------------------------------------------------------------
......
......@@ -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 */
......@@ -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,
......
......@@ -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
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment