mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 13:51:26 +02:00
BUG/MEDIUM: connections: Don't assume the connection has a valid session.
Don't assume the connection always has a valid session in "owner". Instead, attempt to retrieve the session from the stream, and modify the error snapshot code to not assume we always have a session, or the proxy for the other end.
This commit is contained in:
parent
1544c14c57
commit
bdb00c5db9
@ -3136,9 +3136,18 @@ static void fcgi_strm_capture_bad_message(struct fcgi_conn *fconn, struct fcgi_s
|
|||||||
{
|
{
|
||||||
struct session *sess = fstrm->sess;
|
struct session *sess = fstrm->sess;
|
||||||
struct proxy *proxy = fconn->proxy;
|
struct proxy *proxy = fconn->proxy;
|
||||||
struct proxy *other_end = sess->fe;
|
struct proxy *other_end;
|
||||||
union error_snapshot_ctx ctx;
|
union error_snapshot_ctx ctx;
|
||||||
|
|
||||||
|
if (fstrm->cs && fstrm->cs->data) {
|
||||||
|
if (sess == NULL)
|
||||||
|
sess = si_strm(fstrm->cs->data)->sess;
|
||||||
|
if (!(h1m->flags & H1_MF_RESP))
|
||||||
|
other_end = si_strm(fstrm->cs->data)->be;
|
||||||
|
else
|
||||||
|
other_end = sess->fe;
|
||||||
|
} else
|
||||||
|
other_end = NULL;
|
||||||
/* http-specific part now */
|
/* http-specific part now */
|
||||||
ctx.h1.state = h1m->state;
|
ctx.h1.state = h1m->state;
|
||||||
ctx.h1.c_flags = fconn->flags;
|
ctx.h1.c_flags = fconn->flags;
|
||||||
|
11
src/mux_h1.c
11
src/mux_h1.c
@ -1054,11 +1054,18 @@ static void h1_capture_bad_message(struct h1c *h1c, struct h1s *h1s,
|
|||||||
{
|
{
|
||||||
struct session *sess = h1c->conn->owner;
|
struct session *sess = h1c->conn->owner;
|
||||||
struct proxy *proxy = h1c->px;
|
struct proxy *proxy = h1c->px;
|
||||||
struct proxy *other_end = sess->fe;
|
struct proxy *other_end;
|
||||||
union error_snapshot_ctx ctx;
|
union error_snapshot_ctx ctx;
|
||||||
|
|
||||||
if (h1s->cs->data && !(h1m->flags & H1_MF_RESP))
|
if (h1s->cs && h1s->cs->data) {
|
||||||
|
if (sess == NULL)
|
||||||
|
sess = si_strm(h1s->cs->data)->sess;
|
||||||
|
if (!(h1m->flags & H1_MF_RESP))
|
||||||
other_end = si_strm(h1s->cs->data)->be;
|
other_end = si_strm(h1s->cs->data)->be;
|
||||||
|
else
|
||||||
|
other_end = sess->fe;
|
||||||
|
} else
|
||||||
|
other_end = NULL;
|
||||||
|
|
||||||
/* http-specific part now */
|
/* http-specific part now */
|
||||||
ctx.h1.state = h1m->state;
|
ctx.h1.state = h1m->state;
|
||||||
|
10
src/proxy.c
10
src/proxy.c
@ -1560,7 +1560,7 @@ void proxy_capture_error(struct proxy *proxy, int is_back,
|
|||||||
es->when = date; // user-visible date
|
es->when = date; // user-visible date
|
||||||
es->srv = objt_server(target);
|
es->srv = objt_server(target);
|
||||||
es->oe = other_end;
|
es->oe = other_end;
|
||||||
if (objt_conn(sess->origin) && conn_get_src(__objt_conn(sess->origin)))
|
if (sess && objt_conn(sess->origin) && conn_get_src(__objt_conn(sess->origin)))
|
||||||
es->src = *__objt_conn(sess->origin)->src;
|
es->src = *__objt_conn(sess->origin)->src;
|
||||||
else
|
else
|
||||||
memset(&es->src, 0, sizeof(es->src));
|
memset(&es->src, 0, sizeof(es->src));
|
||||||
@ -2234,7 +2234,7 @@ static int cli_io_handler_show_errors(struct appctx *appctx)
|
|||||||
|
|
||||||
if (appctx->ctx.errors.iid >= 0 &&
|
if (appctx->ctx.errors.iid >= 0 &&
|
||||||
appctx->ctx.errors.px->uuid != appctx->ctx.errors.iid &&
|
appctx->ctx.errors.px->uuid != appctx->ctx.errors.iid &&
|
||||||
es->oe->uuid != appctx->ctx.errors.iid)
|
(!es->oe || es->oe->uuid != appctx->ctx.errors.iid))
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
if (appctx->ctx.errors.ptr < 0) {
|
if (appctx->ctx.errors.ptr < 0) {
|
||||||
@ -2264,15 +2264,15 @@ static int cli_io_handler_show_errors(struct appctx *appctx)
|
|||||||
" frontend %s (#%d): invalid request\n"
|
" frontend %s (#%d): invalid request\n"
|
||||||
" backend %s (#%d)",
|
" backend %s (#%d)",
|
||||||
appctx->ctx.errors.px->id, appctx->ctx.errors.px->uuid,
|
appctx->ctx.errors.px->id, appctx->ctx.errors.px->uuid,
|
||||||
(es->oe->cap & PR_CAP_BE) ? es->oe->id : "<NONE>",
|
(es->oe && es->oe->cap & PR_CAP_BE) ? es->oe->id : "<NONE>",
|
||||||
(es->oe->cap & PR_CAP_BE) ? es->oe->uuid : -1);
|
(es->oe && es->oe->cap & PR_CAP_BE) ? es->oe->uuid : -1);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
chunk_appendf(&trash,
|
chunk_appendf(&trash,
|
||||||
" backend %s (#%d): invalid response\n"
|
" backend %s (#%d): invalid response\n"
|
||||||
" frontend %s (#%d)",
|
" frontend %s (#%d)",
|
||||||
appctx->ctx.errors.px->id, appctx->ctx.errors.px->uuid,
|
appctx->ctx.errors.px->id, appctx->ctx.errors.px->uuid,
|
||||||
es->oe->id, es->oe->uuid);
|
es->oe ? es->oe->id : "<NONE>" , es->oe ? es->oe->uuid : -1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user