From bc174aa1444fa5a07b4de250123ac16759cc3c8b Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 19 Nov 2012 16:10:32 +0100 Subject: [PATCH] MINOR: cli: report connection status in "show sess xxx" Connection flags, targets and transport layers are now reported in "show sess $PTR", as it is an absolute requirement in debugging. --- include/proto/checks.h | 2 ++ include/proto/session.h | 2 ++ src/dumpstats.c | 50 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/include/proto/checks.h b/include/proto/checks.h index 69c5d2aadd..042b85405f 100644 --- a/include/proto/checks.h +++ b/include/proto/checks.h @@ -32,6 +32,8 @@ void set_server_up(struct server *s); int start_checks(); void health_adjust(struct server *s, short status); +extern struct data_cb check_conn_cb; + #endif /* _PROTO_CHECKS_H */ /* diff --git a/include/proto/session.h b/include/proto/session.h index a17aa94b2f..463b2e4b02 100644 --- a/include/proto/session.h +++ b/include/proto/session.h @@ -31,6 +31,8 @@ extern struct pool_head *pool2_session; extern struct list sessions; +extern struct data_cb sess_conn_cb; + int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr); /* perform minimal intializations, report 0 in case of error, 1 if OK. */ diff --git a/src/dumpstats.c b/src/dumpstats.c index 8264506d70..cd00e5b77f 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -3478,11 +3478,11 @@ static int stats_dump_full_sess_to_buffer(struct stream_interface *si) human_time(now.tv_sec - sess->logs.accept_date.tv_sec, 1)); chunk_appendf(&trash, - " si[0]=%p (state=%d flags=0x%02x fd=%d exp=%s, et=0x%03x)\n", + " si[0]=%p (state=%d flags=0x%02x conn=%p exp=%s, et=0x%03x)\n", &sess->si[0], sess->si[0].state, sess->si[0].flags, - sess->si[0].conn->t.sock.fd, + sess->si[0].conn, sess->si[0].exp ? tick_is_expired(sess->si[0].exp, now_ms) ? "" : human_time(TICKS_TO_MS(sess->si[0].exp - now_ms), @@ -3490,17 +3490,59 @@ static int stats_dump_full_sess_to_buffer(struct stream_interface *si) sess->si[0].err_type); chunk_appendf(&trash, - " si[1]=%p (state=%d flags=0x%02x fd=%d exp=%s, et=0x%03x)\n", + " si[1]=%p (state=%d flags=0x%02x conn=%p exp=%s, et=0x%03x)\n", &sess->si[1], sess->si[1].state, sess->si[1].flags, - sess->si[1].conn->t.sock.fd, + sess->si[1].conn, sess->si[1].exp ? tick_is_expired(sess->si[1].exp, now_ms) ? "" : human_time(TICKS_TO_MS(sess->si[1].exp - now_ms), TICKS_TO_MS(1000)) : "", sess->si[1].err_type); + chunk_appendf(&trash, + " lconn=%p (ctrl=%p(%s) xprt=%p(%s) data=%p(%s) fd=%d target=%d flags=0x%08x)\n", + sess->si[0].conn, + sess->si[0].conn->ctrl, + sess->si[0].conn->ctrl ? sess->si[0].conn->ctrl->name : "NONE", + sess->si[0].conn->xprt, + (sess->si[0].conn->xprt == NULL) ? "NONE" : + (sess->si[0].conn->xprt == &raw_sock) ? "RAW" : +#ifdef USE_OPENSSL + (sess->si[0].conn->xprt == &ssl_sock) ? "SSL" : +#endif + "????", + sess->si[0].conn->data, + (sess->si[0].conn->data == NULL) ? "NONE" : + (sess->si[0].conn->data == &sess_conn_cb) ? "SESS" : + (sess->si[0].conn->data == &si_conn_cb) ? "STRM" : + (sess->si[0].conn->data == &check_conn_cb) ? "CHCK" : "????", + sess->si[0].conn->t.sock.fd, + sess->si[0].conn->target ? *sess->si[0].conn->target : 0, + sess->si[0].conn->flags); + + chunk_appendf(&trash, + " rconn=%p (ctrl=%p(%s) xprt=%p(%s) data=%p(%s) fd=%d target=%d flags=0x%08x)\n", + sess->si[1].conn, + sess->si[1].conn->ctrl, + sess->si[1].conn->ctrl ? sess->si[1].conn->ctrl->name : "NONE", + sess->si[1].conn->xprt, + (sess->si[1].conn->xprt == NULL) ? "NONE" : + (sess->si[1].conn->xprt == &raw_sock) ? "RAW" : +#ifdef USE_OPENSSL + (sess->si[1].conn->xprt == &ssl_sock) ? "SSL" : +#endif + "UNKNOWN", + sess->si[1].conn->data, + (sess->si[1].conn->data == NULL) ? "NONE" : + (sess->si[1].conn->data == &sess_conn_cb) ? "SESS" : + (sess->si[1].conn->data == &si_conn_cb) ? "STRM" : + (sess->si[1].conn->data == &check_conn_cb) ? "CHCK" : "????", + sess->si[1].conn->t.sock.fd, + sess->si[1].conn->target ? *sess->si[1].conn->target : 0, + sess->si[1].conn->flags); + chunk_appendf(&trash, " txn=%p (flags=0x%x meth=%d status=%d req.st=%d rsp.st=%d)\n", &sess->txn, sess->txn.flags, sess->txn.meth, sess->txn.status, -- 2.39.5