mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
MINOR: stconn: Always report READ/WRITE event on shutr/shutw
It was done by hand by callers when a shutdown for read or write was performed. It is now always handled by the functions performing the shutdown. This way the callers don't take care of it. This will avoid some bugs.
This commit is contained in:
parent
80e4532105
commit
b08c5259eb
@ -1598,7 +1598,6 @@ static void promex_appctx_handle_io(struct appctx *appctx)
|
||||
|
||||
case PROMEX_ST_END:
|
||||
if (!(res->flags & CF_SHUTR)) {
|
||||
res->flags |= CF_READ_EVENT;
|
||||
sc_shutr(sc);
|
||||
}
|
||||
}
|
||||
@ -1614,7 +1613,6 @@ static void promex_appctx_handle_io(struct appctx *appctx)
|
||||
return;
|
||||
|
||||
error:
|
||||
res->flags |= CF_READ_EVENT;
|
||||
sc_shutr(sc);
|
||||
sc_shutw(sc);
|
||||
goto out;
|
||||
|
@ -2023,7 +2023,6 @@ void back_try_conn_req(struct stream *s)
|
||||
sc_shutr(sc);
|
||||
sc_shutw(sc);
|
||||
sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
|
||||
req->flags |= CF_WRITE_EVENT;
|
||||
|
||||
s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
|
||||
|
||||
@ -2184,7 +2183,6 @@ void back_handle_st_req(struct stream *s)
|
||||
sc_shutr(sc);
|
||||
sc_shutw(sc);
|
||||
sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
|
||||
s->req.flags |= CF_WRITE_EVENT;
|
||||
s->conn_err_type = STRM_ET_CONN_RES;
|
||||
sc->state = SC_ST_CLO;
|
||||
if (s->srv_error)
|
||||
@ -2211,7 +2209,6 @@ void back_handle_st_req(struct stream *s)
|
||||
sc_shutr(sc);
|
||||
sc_shutw(sc);
|
||||
sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
|
||||
s->req.flags |= CF_WRITE_EVENT;
|
||||
if (!s->conn_err_type)
|
||||
s->conn_err_type = STRM_ET_CONN_OTHER;
|
||||
sc->state = SC_ST_CLO;
|
||||
@ -2347,8 +2344,6 @@ void back_handle_st_cer(struct stream *s)
|
||||
/* shutw is enough to stop a connecting socket */
|
||||
sc_shutw(sc);
|
||||
sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
|
||||
s->req.flags |= CF_WRITE_EVENT;
|
||||
s->res.flags |= CF_READ_EVENT;
|
||||
|
||||
sc->state = SC_ST_CLO;
|
||||
if (s->srv_error)
|
||||
@ -2382,8 +2377,6 @@ void back_handle_st_cer(struct stream *s)
|
||||
/* shutw is enough to stop a connecting socket */
|
||||
sc_shutw(sc);
|
||||
sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
|
||||
s->req.flags |= CF_WRITE_EVENT;
|
||||
s->res.flags |= CF_READ_EVENT;
|
||||
|
||||
sc->state = SC_ST_CLO;
|
||||
if (s->srv_error)
|
||||
|
@ -1532,10 +1532,8 @@ static void http_cache_io_handler(struct appctx *appctx)
|
||||
}
|
||||
|
||||
end:
|
||||
if (!(res->flags & CF_SHUTR) && appctx->st0 == HTX_CACHE_END) {
|
||||
res->flags |= CF_READ_EVENT;
|
||||
if (!(res->flags & CF_SHUTR) && appctx->st0 == HTX_CACHE_END)
|
||||
sc_shutr(sc);
|
||||
}
|
||||
|
||||
out:
|
||||
total = res_htx->data - total;
|
||||
|
@ -1183,7 +1183,6 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
* on the response buffer.
|
||||
*/
|
||||
sc_shutr(sc);
|
||||
res->flags |= CF_READ_EVENT;
|
||||
}
|
||||
|
||||
out:
|
||||
|
@ -765,7 +765,6 @@ static void dns_session_io_handler(struct appctx *appctx)
|
||||
close:
|
||||
sc_shutw(sc);
|
||||
sc_shutr(sc);
|
||||
sc_ic(sc)->flags |= CF_READ_EVENT;
|
||||
}
|
||||
|
||||
void dns_queries_flush(struct dns_session *ds)
|
||||
|
@ -1303,7 +1303,6 @@ spoe_release_appctx(struct appctx *appctx)
|
||||
|
||||
sc_shutw(sc);
|
||||
sc_shutr(sc);
|
||||
sc_ic(sc)->flags |= CF_READ_EVENT;
|
||||
}
|
||||
|
||||
/* Destroy the task attached to this applet */
|
||||
@ -2022,7 +2021,6 @@ spoe_handle_appctx(struct appctx *appctx)
|
||||
|
||||
sc_shutw(sc);
|
||||
sc_shutr(sc);
|
||||
sc_ic(sc)->flags |= CF_READ_EVENT;
|
||||
__fallthrough;
|
||||
|
||||
case SPOE_APPCTX_ST_END:
|
||||
|
@ -2003,7 +2003,6 @@ static void hlua_socket_handler(struct appctx *appctx)
|
||||
if (ctx->die) {
|
||||
sc_shutw(sc);
|
||||
sc_shutr(sc);
|
||||
sc_ic(sc)->flags |= CF_READ_EVENT;
|
||||
notification_wake(&ctx->wake_on_read);
|
||||
notification_wake(&ctx->wake_on_write);
|
||||
stream_shutdown(__sc_strm(sc), SF_ERR_KILLED);
|
||||
@ -9426,7 +9425,6 @@ void hlua_applet_tcp_fct(struct appctx *ctx)
|
||||
struct hlua_tcp_ctx *tcp_ctx = ctx->svcctx;
|
||||
struct stconn *sc = appctx_sc(ctx);
|
||||
struct stream *strm = __sc_strm(sc);
|
||||
struct channel *res = sc_ic(sc);
|
||||
struct act_rule *rule = ctx->rule;
|
||||
struct proxy *px = strm->be;
|
||||
struct hlua *hlua = tcp_ctx->hlua;
|
||||
@ -9450,7 +9448,6 @@ void hlua_applet_tcp_fct(struct appctx *ctx)
|
||||
|
||||
/* eat the whole request */
|
||||
co_skip(sc_oc(sc), co_data(sc_oc(sc)));
|
||||
res->flags |= CF_READ_EVENT;
|
||||
sc_shutr(sc);
|
||||
return;
|
||||
|
||||
@ -9732,10 +9729,8 @@ void hlua_applet_http_fct(struct appctx *ctx)
|
||||
|
||||
done:
|
||||
if (http_ctx->flags & APPLET_DONE) {
|
||||
if (!(res->flags & CF_SHUTR)) {
|
||||
res->flags |= CF_READ_EVENT;
|
||||
if (!(res->flags & CF_SHUTR))
|
||||
sc_shutr(sc);
|
||||
}
|
||||
|
||||
/* eat the whole request */
|
||||
if (co_data(req)) {
|
||||
|
@ -3688,9 +3688,6 @@ static void syslog_io_handler(struct appctx *appctx)
|
||||
close:
|
||||
sc_shutw(sc);
|
||||
sc_shutr(sc);
|
||||
|
||||
sc_ic(sc)->flags |= CF_READ_EVENT;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3195,7 +3195,6 @@ static void peer_io_handler(struct appctx *appctx)
|
||||
}
|
||||
sc_shutw(sc);
|
||||
sc_shutr(sc);
|
||||
sc_ic(sc)->flags |= CF_READ_EVENT;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -443,7 +443,6 @@ static void sink_forward_io_handler(struct appctx *appctx)
|
||||
close:
|
||||
sc_shutw(sc);
|
||||
sc_shutr(sc);
|
||||
sc_ic(sc)->flags |= CF_READ_EVENT;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -585,7 +584,6 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
|
||||
close:
|
||||
sc_shutw(sc);
|
||||
sc_shutr(sc);
|
||||
sc_ic(sc)->flags |= CF_READ_EVENT;
|
||||
}
|
||||
|
||||
void __sink_forward_session_deinit(struct sink_forward_target *sft)
|
||||
|
@ -4506,10 +4506,8 @@ static void http_stats_io_handler(struct appctx *appctx)
|
||||
}
|
||||
|
||||
if (appctx->st0 == STAT_HTTP_END) {
|
||||
if (!(res->flags & CF_SHUTR)) {
|
||||
res->flags |= CF_READ_EVENT;
|
||||
if (!(res->flags & CF_SHUTR))
|
||||
sc_shutr(sc);
|
||||
}
|
||||
|
||||
/* eat the whole request */
|
||||
if (co_data(req)) {
|
||||
|
18
src/stconn.c
18
src/stconn.c
@ -533,8 +533,8 @@ static void sc_app_shutr(struct stconn *sc)
|
||||
struct channel *ic = sc_ic(sc);
|
||||
|
||||
if (ic->flags & CF_SHUTR)
|
||||
return;
|
||||
ic->flags |= CF_SHUTR;
|
||||
|
||||
ic->flags |= CF_SHUTR|CF_READ_EVENT;
|
||||
sc_ep_report_read_activity(sc);
|
||||
sc_ep_reset_rex(sc);
|
||||
|
||||
@ -569,7 +569,7 @@ static void sc_app_shutw(struct stconn *sc)
|
||||
oc->flags &= ~CF_SHUTW_NOW;
|
||||
if (oc->flags & CF_SHUTW)
|
||||
return;
|
||||
oc->flags |= CF_SHUTW;
|
||||
oc->flags |= CF_SHUTW|CF_WRITE_EVENT;
|
||||
sc_ep_reset_wex(sc);
|
||||
|
||||
if (tick_isset(sc->hcto)) {
|
||||
@ -676,7 +676,7 @@ static void sc_app_shutr_conn(struct stconn *sc)
|
||||
|
||||
if (ic->flags & CF_SHUTR)
|
||||
return;
|
||||
ic->flags |= CF_SHUTR;
|
||||
ic->flags |= CF_SHUTR|CF_READ_EVENT;
|
||||
sc_ep_reset_rex(sc);
|
||||
|
||||
if (!sc_state_in(sc->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
@ -710,7 +710,7 @@ static void sc_app_shutw_conn(struct stconn *sc)
|
||||
oc->flags &= ~CF_SHUTW_NOW;
|
||||
if (oc->flags & CF_SHUTW)
|
||||
return;
|
||||
oc->flags |= CF_SHUTW;
|
||||
oc->flags |= CF_SHUTW|CF_WRITE_EVENT;
|
||||
sc_ep_reset_wex(sc);
|
||||
|
||||
if (tick_isset(sc->hcto)) {
|
||||
@ -898,7 +898,7 @@ static void sc_app_shutr_applet(struct stconn *sc)
|
||||
|
||||
if (ic->flags & CF_SHUTR)
|
||||
return;
|
||||
ic->flags |= CF_SHUTR;
|
||||
ic->flags |= CF_SHUTR|CF_READ_EVENT;
|
||||
sc_ep_reset_rex(sc);
|
||||
|
||||
/* Note: on shutr, we don't call the applet */
|
||||
@ -933,7 +933,7 @@ static void sc_app_shutw_applet(struct stconn *sc)
|
||||
oc->flags &= ~CF_SHUTW_NOW;
|
||||
if (oc->flags & CF_SHUTW)
|
||||
return;
|
||||
oc->flags |= CF_SHUTW;
|
||||
oc->flags |= CF_SHUTW|CF_WRITE_EVENT;
|
||||
sc_ep_reset_wex(sc);
|
||||
|
||||
if (tick_isset(sc->hcto)) {
|
||||
@ -1240,7 +1240,7 @@ static void sc_conn_read0(struct stconn *sc)
|
||||
|
||||
if (ic->flags & CF_SHUTR)
|
||||
return;
|
||||
ic->flags |= CF_SHUTR;
|
||||
ic->flags |= CF_SHUTR|CF_READ_EVENT;
|
||||
sc_ep_report_read_activity(sc);
|
||||
sc_ep_reset_rex(sc);
|
||||
|
||||
@ -1589,7 +1589,6 @@ static int sc_conn_recv(struct stconn *sc)
|
||||
ret = 1;
|
||||
else if (sc_ep_test(sc, SE_FL_EOS)) {
|
||||
/* we received a shutdown */
|
||||
ic->flags |= CF_READ_EVENT;
|
||||
if (ic->flags & CF_AUTO_CLOSE)
|
||||
channel_shutw_now(ic);
|
||||
sc_conn_read0(sc);
|
||||
@ -1874,7 +1873,6 @@ static int sc_conn_process(struct stconn *sc)
|
||||
*/
|
||||
if (sc_ep_test(sc, SE_FL_EOS) && !(ic->flags & CF_SHUTR)) {
|
||||
/* we received a shutdown */
|
||||
ic->flags |= CF_READ_EVENT;
|
||||
if (ic->flags & CF_AUTO_CLOSE)
|
||||
channel_shutw_now(ic);
|
||||
sc_conn_read0(sc);
|
||||
|
Loading…
Reference in New Issue
Block a user