mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-06 19:38:22 +00:00
MINOR: mux-h1: split "show_fd" into connection and stream
We now have two functions, one for dumping connections and the other one for dumping the streams. This will permit to use it from show_sd. A few optional line breaks were inserted where relevant to keep lines homogenous when a prefix is passed.
This commit is contained in:
parent
b4a4feee87
commit
7079c0fbbd
109
src/mux_h1.c
109
src/mux_h1.c
@ -3901,6 +3901,77 @@ static int h1_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *outp
|
||||
}
|
||||
}
|
||||
|
||||
/* appends some info about connection <h1c> to buffer <msg>, or does nothing if
|
||||
* <h1c> is NULL. Returns non-zero if the connection is considered suspicious.
|
||||
* May emit multiple lines, each new one being prefixed with <pfx>, if <pfx> is
|
||||
* not NULL, otherwise a single line is used.
|
||||
*/
|
||||
static int h1_dump_h1c_info(struct buffer *msg, struct h1c *h1c, const char *pfx)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!h1c)
|
||||
return ret;
|
||||
|
||||
chunk_appendf(msg, " h1c.flg=0x%x .sub=%d .ibuf=%u@%p+%u/%u .obuf=%u@%p+%u/%u",
|
||||
h1c->flags, h1c->wait_event.events,
|
||||
(unsigned int)b_data(&h1c->ibuf), b_orig(&h1c->ibuf),
|
||||
(unsigned int)b_head_ofs(&h1c->ibuf), (unsigned int)b_size(&h1c->ibuf),
|
||||
(unsigned int)b_data(&h1c->obuf), b_orig(&h1c->obuf),
|
||||
(unsigned int)b_head_ofs(&h1c->obuf), (unsigned int)b_size(&h1c->obuf));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* appends some info about stream <h1s> to buffer <msg>, or does nothing if
|
||||
* <h1s> is NULL. Returns non-zero if the stream is considered suspicious. May
|
||||
* emit multiple lines, each new one being prefixed with <pfx>, if <pfx> is not
|
||||
* NULL, otherwise a single line is used.
|
||||
*/
|
||||
static int h1_dump_h1s_info(struct buffer *msg, const struct h1s *h1s, const char *pfx)
|
||||
{
|
||||
const char *method;
|
||||
int ret = 0;
|
||||
|
||||
if (!h1s)
|
||||
return ret;
|
||||
|
||||
if (h1s->meth < HTTP_METH_OTHER)
|
||||
method = http_known_methods[h1s->meth].ptr;
|
||||
else
|
||||
method = "UNKNOWN";
|
||||
|
||||
chunk_appendf(msg, " h1s=%p h1s.flg=0x%x .sd.flg=0x%x .req.state=%s .res.state=%s",
|
||||
h1s, h1s->flags, se_fl_get(h1s->sd),
|
||||
h1m_state_str(h1s->req.state), h1m_state_str(h1s->res.state));
|
||||
|
||||
if (pfx)
|
||||
chunk_appendf(msg, "\n%s", pfx);
|
||||
|
||||
chunk_appendf(msg, " .meth=%s status=%d",
|
||||
method, h1s->status);
|
||||
|
||||
chunk_appendf(msg, " .sd.flg=0x%08x", se_fl_get(h1s->sd));
|
||||
if (!se_fl_test(h1s->sd, SE_FL_ORPHAN))
|
||||
chunk_appendf(msg, " .sc.flg=0x%08x .sc.app=%p",
|
||||
h1s_sc(h1s)->flags, h1s_sc(h1s)->app);
|
||||
|
||||
if (pfx && h1s->subs)
|
||||
chunk_appendf(msg, "\n%s", pfx);
|
||||
|
||||
chunk_appendf(msg, " .subs=%p", h1s->subs);
|
||||
if (h1s->subs) {
|
||||
chunk_appendf(msg, "(ev=%d tl=%p", h1s->subs->events, h1s->subs->tasklet);
|
||||
chunk_appendf(msg, " tl.calls=%d tl.ctx=%p tl.fct=",
|
||||
h1s->subs->tasklet->calls,
|
||||
h1s->subs->tasklet->context);
|
||||
if (h1s->subs->tasklet->calls >= 1000000)
|
||||
ret = 1;
|
||||
resolve_sym_name(msg, NULL, h1s->subs->tasklet->process);
|
||||
chunk_appendf(msg, ")");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* for debugging with CLI's "show fd" command */
|
||||
static int h1_show_fd(struct buffer *msg, struct connection *conn)
|
||||
{
|
||||
@ -3908,43 +3979,11 @@ static int h1_show_fd(struct buffer *msg, struct connection *conn)
|
||||
struct h1s *h1s = h1c->h1s;
|
||||
int ret = 0;
|
||||
|
||||
chunk_appendf(msg, " h1c.flg=0x%x .sub=%d .ibuf=%u@%p+%u/%u .obuf=%u@%p+%u/%u",
|
||||
h1c->flags, h1c->wait_event.events,
|
||||
(unsigned int)b_data(&h1c->ibuf), b_orig(&h1c->ibuf),
|
||||
(unsigned int)b_head_ofs(&h1c->ibuf), (unsigned int)b_size(&h1c->ibuf),
|
||||
(unsigned int)b_data(&h1c->obuf), b_orig(&h1c->obuf),
|
||||
(unsigned int)b_head_ofs(&h1c->obuf), (unsigned int)b_size(&h1c->obuf));
|
||||
ret |= h1_dump_h1c_info(msg, h1c, NULL);
|
||||
|
||||
if (h1s) {
|
||||
char *method;
|
||||
if (h1s)
|
||||
ret |= h1_dump_h1s_info(msg, h1s, NULL);
|
||||
|
||||
if (h1s->meth < HTTP_METH_OTHER)
|
||||
method = http_known_methods[h1s->meth].ptr;
|
||||
else
|
||||
method = "UNKNOWN";
|
||||
chunk_appendf(msg, " h1s=%p h1s.flg=0x%x .sd.flg=0x%x .req.state=%s .res.state=%s"
|
||||
" .meth=%s status=%d",
|
||||
h1s, h1s->flags, se_fl_get(h1s->sd),
|
||||
h1m_state_str(h1s->req.state),
|
||||
h1m_state_str(h1s->res.state), method, h1s->status);
|
||||
|
||||
chunk_appendf(msg, " .sd.flg=0x%08x", se_fl_get(h1s->sd));
|
||||
if (!se_fl_test(h1s->sd, SE_FL_ORPHAN))
|
||||
chunk_appendf(msg, " .sc.flg=0x%08x .sc.app=%p",
|
||||
h1s_sc(h1s)->flags, h1s_sc(h1s)->app);
|
||||
|
||||
chunk_appendf(msg, " .subs=%p", h1s->subs);
|
||||
if (h1s->subs) {
|
||||
chunk_appendf(msg, "(ev=%d tl=%p", h1s->subs->events, h1s->subs->tasklet);
|
||||
chunk_appendf(msg, " tl.calls=%d tl.ctx=%p tl.fct=",
|
||||
h1s->subs->tasklet->calls,
|
||||
h1s->subs->tasklet->context);
|
||||
if (h1s->subs->tasklet->calls >= 1000000)
|
||||
ret = 1;
|
||||
resolve_sym_name(msg, NULL, h1s->subs->tasklet->process);
|
||||
chunk_appendf(msg, ")");
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user