mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-08 02:40:24 +00:00
MINOR: mux-h1: add a trace context filling helper
This helper is able to find a connection, a session, a stream, a frontend or a backend from its args.
This commit is contained in:
parent
6c6ef5ae12
commit
adfe0a30e1
31
src/mux_h1.c
31
src/mux_h1.c
@ -100,6 +100,9 @@ static void h1_trace(enum trace_level level, uint64_t mask,
|
||||
const struct ist where, const struct ist func,
|
||||
const void *a1, const void *a2, const void *a3, const void *a4);
|
||||
|
||||
static void h1_trace_fill_ctx(struct trace_ctx *ctx, const struct trace_source *src,
|
||||
const void *a1, const void *a2, const void *a3, const void *a4);
|
||||
|
||||
/* The event representation is split like this :
|
||||
* h1c - internal H1 connection
|
||||
* h1s - internal H1 stream
|
||||
@ -199,6 +202,7 @@ static struct trace_source trace_h1 __read_mostly = {
|
||||
.desc = "HTTP/1 multiplexer",
|
||||
.arg_def = TRC_ARG1_CONN, // TRACE()'s first argument is always a connection
|
||||
.default_cb = h1_trace,
|
||||
.fill_ctx = h1_trace_fill_ctx,
|
||||
.known_events = h1_trace_events,
|
||||
.lockon_args = h1_trace_lockon_args,
|
||||
.decoding = h1_trace_decoding,
|
||||
@ -453,6 +457,33 @@ static void h1_trace(enum trace_level level, uint64_t mask, const struct trace_s
|
||||
}
|
||||
}
|
||||
|
||||
/* This fills the trace_ctx with extra info guessed from the args */
|
||||
static void h1_trace_fill_ctx(struct trace_ctx *ctx, const struct trace_source *src,
|
||||
const void *a1, const void *a2, const void *a3, const void *a4)
|
||||
{
|
||||
const struct connection *conn = a1;
|
||||
const struct h1c *h1c = conn ? conn->ctx : NULL;
|
||||
const struct h1s *h1s = a2;
|
||||
|
||||
if (!ctx->conn)
|
||||
ctx->conn = conn;
|
||||
|
||||
if (h1c) {
|
||||
if (!ctx->fe && !(h1c->flags & H1C_F_IS_BACK))
|
||||
ctx->fe = h1c->px;
|
||||
|
||||
if (!ctx->be && (h1c->flags & H1C_F_IS_BACK))
|
||||
ctx->be = h1c->px;
|
||||
}
|
||||
|
||||
if (h1s) {
|
||||
if (!ctx->sess)
|
||||
ctx->sess = h1s->sess;
|
||||
if (!ctx->strm && h1s->sd && h1s_sc(h1s))
|
||||
ctx->strm = sc_strm(h1s_sc(h1s));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************/
|
||||
/* functions below are for dynamic buffer management */
|
||||
|
Loading…
Reference in New Issue
Block a user