mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-12-16 23:21:01 +01:00
CLEANUP: mux-pt: always take the endp from the context not the cs
At a few places the endpoint pointer was retrieved from the conn_stream while it's safer and more long-term proof to take it from the context. Let's just do that.
This commit is contained in:
parent
aff21f9a96
commit
7a2705f921
34
src/mux_pt.c
34
src/mux_pt.c
@ -460,18 +460,19 @@ static int mux_pt_avail_streams(struct connection *conn)
|
|||||||
static void mux_pt_shutr(struct conn_stream *cs, enum co_shr_mode mode)
|
static void mux_pt_shutr(struct conn_stream *cs, enum co_shr_mode mode)
|
||||||
{
|
{
|
||||||
struct connection *conn = __cs_conn(cs);
|
struct connection *conn = __cs_conn(cs);
|
||||||
|
struct mux_pt_ctx *ctx = conn->ctx;
|
||||||
|
|
||||||
TRACE_ENTER(PT_EV_STRM_SHUT, conn, cs);
|
TRACE_ENTER(PT_EV_STRM_SHUT, conn, cs);
|
||||||
|
|
||||||
if (cs->endp->flags & CS_EP_SHR)
|
if (ctx->endp->flags & CS_EP_SHR)
|
||||||
return;
|
return;
|
||||||
cs->endp->flags &= ~(CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
|
ctx->endp->flags &= ~(CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
|
||||||
if (conn_xprt_ready(conn) && conn->xprt->shutr)
|
if (conn_xprt_ready(conn) && conn->xprt->shutr)
|
||||||
conn->xprt->shutr(conn, conn->xprt_ctx,
|
conn->xprt->shutr(conn, conn->xprt_ctx,
|
||||||
(mode == CO_SHR_DRAIN));
|
(mode == CO_SHR_DRAIN));
|
||||||
else if (mode == CO_SHR_DRAIN)
|
else if (mode == CO_SHR_DRAIN)
|
||||||
conn_ctrl_drain(conn);
|
conn_ctrl_drain(conn);
|
||||||
if (cs->endp->flags & CS_EP_SHW)
|
if (ctx->endp->flags & CS_EP_SHW)
|
||||||
conn_full_close(conn);
|
conn_full_close(conn);
|
||||||
|
|
||||||
TRACE_LEAVE(PT_EV_STRM_SHUT, conn, cs);
|
TRACE_LEAVE(PT_EV_STRM_SHUT, conn, cs);
|
||||||
@ -480,15 +481,16 @@ static void mux_pt_shutr(struct conn_stream *cs, enum co_shr_mode mode)
|
|||||||
static void mux_pt_shutw(struct conn_stream *cs, enum co_shw_mode mode)
|
static void mux_pt_shutw(struct conn_stream *cs, enum co_shw_mode mode)
|
||||||
{
|
{
|
||||||
struct connection *conn = __cs_conn(cs);
|
struct connection *conn = __cs_conn(cs);
|
||||||
|
struct mux_pt_ctx *ctx = conn->ctx;
|
||||||
|
|
||||||
TRACE_ENTER(PT_EV_STRM_SHUT, conn, cs);
|
TRACE_ENTER(PT_EV_STRM_SHUT, conn, cs);
|
||||||
|
|
||||||
if (cs->endp->flags & CS_EP_SHW)
|
if (ctx->endp->flags & CS_EP_SHW)
|
||||||
return;
|
return;
|
||||||
if (conn_xprt_ready(conn) && conn->xprt->shutw)
|
if (conn_xprt_ready(conn) && conn->xprt->shutw)
|
||||||
conn->xprt->shutw(conn, conn->xprt_ctx,
|
conn->xprt->shutw(conn, conn->xprt_ctx,
|
||||||
(mode == CO_SHW_NORMAL));
|
(mode == CO_SHW_NORMAL));
|
||||||
if (!(cs->endp->flags & CS_EP_SHR))
|
if (!(ctx->endp->flags & CS_EP_SHR))
|
||||||
conn_sock_shutw(conn, (mode == CO_SHW_NORMAL));
|
conn_sock_shutw(conn, (mode == CO_SHW_NORMAL));
|
||||||
else
|
else
|
||||||
conn_full_close(conn);
|
conn_full_close(conn);
|
||||||
@ -512,24 +514,25 @@ static void mux_pt_shutw(struct conn_stream *cs, enum co_shw_mode mode)
|
|||||||
static size_t mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
|
static size_t mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
|
||||||
{
|
{
|
||||||
struct connection *conn = __cs_conn(cs);
|
struct connection *conn = __cs_conn(cs);
|
||||||
|
struct mux_pt_ctx *ctx = conn->ctx;
|
||||||
size_t ret = 0;
|
size_t ret = 0;
|
||||||
|
|
||||||
TRACE_ENTER(PT_EV_RX_DATA, conn, cs, buf, (size_t[]){count});
|
TRACE_ENTER(PT_EV_RX_DATA, conn, cs, buf, (size_t[]){count});
|
||||||
|
|
||||||
if (!count) {
|
if (!count) {
|
||||||
cs->endp->flags |= (CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
|
ctx->endp->flags |= (CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
b_realign_if_empty(buf);
|
b_realign_if_empty(buf);
|
||||||
ret = conn->xprt->rcv_buf(conn, conn->xprt_ctx, buf, count, flags);
|
ret = conn->xprt->rcv_buf(conn, conn->xprt_ctx, buf, count, flags);
|
||||||
if (conn_xprt_read0_pending(conn)) {
|
if (conn_xprt_read0_pending(conn)) {
|
||||||
cs->endp->flags &= ~(CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
|
ctx->endp->flags &= ~(CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
|
||||||
cs->endp->flags |= CS_EP_EOS;
|
ctx->endp->flags |= CS_EP_EOS;
|
||||||
TRACE_DEVEL("read0 on connection", PT_EV_RX_DATA, conn, cs);
|
TRACE_DEVEL("read0 on connection", PT_EV_RX_DATA, conn, cs);
|
||||||
}
|
}
|
||||||
if (conn->flags & CO_FL_ERROR) {
|
if (conn->flags & CO_FL_ERROR) {
|
||||||
cs->endp->flags &= ~(CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
|
ctx->endp->flags &= ~(CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
|
||||||
cs->endp->flags |= CS_EP_ERROR;
|
ctx->endp->flags |= CS_EP_ERROR;
|
||||||
TRACE_DEVEL("error on connection", PT_EV_RX_DATA|PT_EV_CONN_ERR, conn, cs);
|
TRACE_DEVEL("error on connection", PT_EV_RX_DATA|PT_EV_CONN_ERR, conn, cs);
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
@ -541,6 +544,7 @@ static size_t mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t
|
|||||||
static size_t mux_pt_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
|
static size_t mux_pt_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
|
||||||
{
|
{
|
||||||
struct connection *conn = __cs_conn(cs);
|
struct connection *conn = __cs_conn(cs);
|
||||||
|
struct mux_pt_ctx *ctx = conn->ctx;
|
||||||
size_t ret;
|
size_t ret;
|
||||||
|
|
||||||
TRACE_ENTER(PT_EV_TX_DATA, conn, cs, buf, (size_t[]){count});
|
TRACE_ENTER(PT_EV_TX_DATA, conn, cs, buf, (size_t[]){count});
|
||||||
@ -551,7 +555,7 @@ static size_t mux_pt_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t
|
|||||||
b_del(buf, ret);
|
b_del(buf, ret);
|
||||||
|
|
||||||
if (conn->flags & CO_FL_ERROR) {
|
if (conn->flags & CO_FL_ERROR) {
|
||||||
cs->endp->flags |= CS_EP_ERROR;
|
ctx->endp->flags |= CS_EP_ERROR;
|
||||||
TRACE_DEVEL("error on connection", PT_EV_TX_DATA|PT_EV_CONN_ERR, conn, cs);
|
TRACE_DEVEL("error on connection", PT_EV_TX_DATA|PT_EV_CONN_ERR, conn, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,17 +593,18 @@ static int mux_pt_unsubscribe(struct conn_stream *cs, int event_type, struct wai
|
|||||||
static int mux_pt_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int count)
|
static int mux_pt_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int count)
|
||||||
{
|
{
|
||||||
struct connection *conn = __cs_conn(cs);
|
struct connection *conn = __cs_conn(cs);
|
||||||
|
struct mux_pt_ctx *ctx = conn->ctx;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
TRACE_ENTER(PT_EV_RX_DATA, conn, cs, 0, (size_t[]){count});
|
TRACE_ENTER(PT_EV_RX_DATA, conn, cs, 0, (size_t[]){count});
|
||||||
|
|
||||||
ret = conn->xprt->rcv_pipe(conn, conn->xprt_ctx, pipe, count);
|
ret = conn->xprt->rcv_pipe(conn, conn->xprt_ctx, pipe, count);
|
||||||
if (conn_xprt_read0_pending(conn)) {
|
if (conn_xprt_read0_pending(conn)) {
|
||||||
cs->endp->flags |= CS_EP_EOS;
|
ctx->endp->flags |= CS_EP_EOS;
|
||||||
TRACE_DEVEL("read0 on connection", PT_EV_RX_DATA, conn, cs);
|
TRACE_DEVEL("read0 on connection", PT_EV_RX_DATA, conn, cs);
|
||||||
}
|
}
|
||||||
if (conn->flags & CO_FL_ERROR) {
|
if (conn->flags & CO_FL_ERROR) {
|
||||||
cs->endp->flags |= CS_EP_ERROR;
|
ctx->endp->flags |= CS_EP_ERROR;
|
||||||
TRACE_DEVEL("error on connection", PT_EV_RX_DATA|PT_EV_CONN_ERR, conn, cs);
|
TRACE_DEVEL("error on connection", PT_EV_RX_DATA|PT_EV_CONN_ERR, conn, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,6 +615,7 @@ static int mux_pt_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned i
|
|||||||
static int mux_pt_snd_pipe(struct conn_stream *cs, struct pipe *pipe)
|
static int mux_pt_snd_pipe(struct conn_stream *cs, struct pipe *pipe)
|
||||||
{
|
{
|
||||||
struct connection *conn = __cs_conn(cs);
|
struct connection *conn = __cs_conn(cs);
|
||||||
|
struct mux_pt_ctx *ctx = conn->ctx;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
TRACE_ENTER(PT_EV_TX_DATA, conn, cs, 0, (size_t[]){pipe->data});
|
TRACE_ENTER(PT_EV_TX_DATA, conn, cs, 0, (size_t[]){pipe->data});
|
||||||
@ -617,7 +623,7 @@ static int mux_pt_snd_pipe(struct conn_stream *cs, struct pipe *pipe)
|
|||||||
ret = conn->xprt->snd_pipe(conn, conn->xprt_ctx, pipe);
|
ret = conn->xprt->snd_pipe(conn, conn->xprt_ctx, pipe);
|
||||||
|
|
||||||
if (conn->flags & CO_FL_ERROR) {
|
if (conn->flags & CO_FL_ERROR) {
|
||||||
cs->endp->flags |= CS_EP_ERROR;
|
ctx->endp->flags |= CS_EP_ERROR;
|
||||||
TRACE_DEVEL("error on connection", PT_EV_TX_DATA|PT_EV_CONN_ERR, conn, cs);
|
TRACE_DEVEL("error on connection", PT_EV_TX_DATA|PT_EV_CONN_ERR, conn, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user