MINOR: channel/applets: Stop to test CF_WRITE_ERROR flag if CF_SHUTW is enough

In applets, we stop processing when a write error (CF_WRITE_ERROR) or a shutdown
for writes (CF_SHUTW) is detected. However, any write error leads to an
immediate shutdown for writes. Thus, it is enough to only test if CF_SHUTW is
set.
This commit is contained in:
Christopher Faulet 2023-01-04 14:11:10 +01:00
parent 4b490b7517
commit da89e9b95b
15 changed files with 24 additions and 26 deletions

View File

@ -534,7 +534,7 @@ static inline void channel_check_timeouts(struct channel *chn)
unlikely(tick_is_expired(chn->rex, now_ms))) unlikely(tick_is_expired(chn->rex, now_ms)))
chn->flags |= CF_READ_TIMEOUT; chn->flags |= CF_READ_TIMEOUT;
if (likely(!(chn->flags & (CF_SHUTW|CF_WRITE_TIMEOUT|CF_WRITE_EVENT|CF_WRITE_ERROR))) && if (likely(!(chn->flags & (CF_SHUTW|CF_WRITE_TIMEOUT|CF_WRITE_EVENT))) &&
unlikely(tick_is_expired(chn->wex, now_ms))) unlikely(tick_is_expired(chn->wex, now_ms)))
chn->flags |= CF_WRITE_TIMEOUT; chn->flags |= CF_WRITE_TIMEOUT;

View File

@ -624,7 +624,7 @@ static int cli_io_handler_show_profiling(struct appctx *appctx)
int max_lines; int max_lines;
int i, j, max; int i, j, max;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
return 1; return 1;
chunk_reset(&trash); chunk_reset(&trash);
@ -887,7 +887,7 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
int thr, queue; int thr, queue;
int i, max; int i, max;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
return 1; return 1;
/* It's not possible to scan queues in small chunks and yield in the /* It's not possible to scan queues in small chunks and yield in the
@ -1027,7 +1027,7 @@ static int cli_io_handler_show_activity(struct appctx *appctx)
struct timeval up; struct timeval up;
int thr; int thr;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
return 1; return 1;
chunk_reset(&trash); chunk_reset(&trash);

View File

@ -1227,7 +1227,7 @@ static int cli_io_handler_show_env(struct appctx *appctx)
struct stconn *sc = appctx_sc(appctx); struct stconn *sc = appctx_sc(appctx);
char **var = ctx->var; char **var = ctx->var;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
return 1; return 1;
chunk_reset(&trash); chunk_reset(&trash);
@ -1264,7 +1264,7 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
int fd = fdctx->fd; int fd = fdctx->fd;
int ret = 1; int ret = 1;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
goto end; goto end;
chunk_reset(&trash); chunk_reset(&trash);

View File

@ -313,7 +313,7 @@ static int cli_io_handler_show_threads(struct appctx *appctx)
struct stconn *sc = appctx_sc(appctx); struct stconn *sc = appctx_sc(appctx);
int thr; int thr;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
return 1; return 1;
if (appctx->st0) if (appctx->st0)
@ -1096,7 +1096,7 @@ static int debug_iohandler_fd(struct appctx *appctx)
int ret = 1; int ret = 1;
int i, fd; int i, fd;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
goto end; goto end;
chunk_reset(&trash); chunk_reset(&trash);
@ -1303,7 +1303,7 @@ static int debug_iohandler_memstats(struct appctx *appctx)
const char *pfx = ctx->match; const char *pfx = ctx->match;
int ret = 1; int ret = 1;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
goto end; goto end;
if (!ctx->width) { if (!ctx->width) {

View File

@ -459,8 +459,7 @@ static void dns_session_io_handler(struct appctx *appctx)
if (ds->shutdown) if (ds->shutdown)
goto close; goto close;
/* an error was detected */ if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
goto close; goto close;
/* con closed by server side, we will skip data write and drain data from channel */ /* con closed by server side, we will skip data write and drain data from channel */

View File

@ -348,7 +348,7 @@ static int cli_io_handler_pat_list(struct appctx *appctx)
struct stconn *sc = appctx_sc(appctx); struct stconn *sc = appctx_sc(appctx);
struct pat_ref_elt *elt; struct pat_ref_elt *elt;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) { if (unlikely(sc_ic(sc)->flags & CF_SHUTW)) {
/* If we're forced to shut down, we might have to remove our /* If we're forced to shut down, we might have to remove our
* reference to the last ref_elt being dumped. * reference to the last ref_elt being dumped.
*/ */

View File

@ -534,7 +534,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
char *uptime = NULL; char *uptime = NULL;
char *reloadtxt = NULL; char *reloadtxt = NULL;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
return 1; return 1;
chunk_reset(&trash); chunk_reset(&trash);
@ -669,7 +669,7 @@ static int cli_io_handler_show_loadstatus(struct appctx *appctx)
if (!cli_has_level(appctx, ACCESS_LVL_OPER)) if (!cli_has_level(appctx, ACCESS_LVL_OPER))
return 1; return 1;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
return 1; return 1;

View File

@ -3189,7 +3189,7 @@ static int cli_io_handler_show_errors(struct appctx *appctx)
struct stconn *sc = appctx_sc(appctx); struct stconn *sc = appctx_sc(appctx);
extern const char *monthname[12]; extern const char *monthname[12];
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
return 1; return 1;
chunk_reset(&trash); chunk_reset(&trash);

View File

@ -347,7 +347,7 @@ int cli_io_handler_show_ring(struct appctx *appctx)
size_t len, cnt; size_t len, cnt;
int ret; int ret;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
return 1; return 1;
HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock); HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);

View File

@ -330,8 +330,7 @@ static void sink_forward_io_handler(struct appctx *appctx)
/* rto should not change but it seems the case */ /* rto should not change but it seems the case */
sc_oc(sc)->rto = TICK_ETERNITY; sc_oc(sc)->rto = TICK_ETERNITY;
/* an error was detected */ if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
goto close; goto close;
/* con closed by server side */ /* con closed by server side */
@ -480,7 +479,7 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
sc_oc(sc)->rto = TICK_ETERNITY; sc_oc(sc)->rto = TICK_ETERNITY;
/* an error was detected */ /* an error was detected */
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
goto close; goto close;
/* con closed by server side */ /* con closed by server side */

View File

@ -2148,7 +2148,7 @@ static int cli_io_handler_commit_cert(struct appctx *appctx)
struct ckch_store *old_ckchs, *new_ckchs = NULL; struct ckch_store *old_ckchs, *new_ckchs = NULL;
struct ckch_inst *ckchi; struct ckch_inst *ckchi;
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
goto end; goto end;
while (1) { while (1) {

View File

@ -1098,7 +1098,7 @@ static int cli_io_handler_add_crtlist(struct appctx *appctx)
/* for each bind_conf which use the crt-list, a new ckch_inst must be /* for each bind_conf which use the crt-list, a new ckch_inst must be
* created. * created.
*/ */
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
goto end; goto end;
switch (ctx->state) { switch (ctx->state) {

View File

@ -850,7 +850,7 @@ static void sc_app_chk_snd_conn(struct stconn *sc)
/* in case of special condition (error, shutdown, end of write...), we /* in case of special condition (error, shutdown, end of write...), we
* have to notify the task. * have to notify the task.
*/ */
if (likely((oc->flags & (CF_WRITE_EVENT|CF_WRITE_ERROR|CF_SHUTW)) || if (likely((oc->flags & (CF_WRITE_EVENT|CF_SHUTW)) ||
((oc->flags & CF_WAKE_WRITE) && ((oc->flags & CF_WAKE_WRITE) &&
((channel_is_empty(oc) && !oc->to_forward) || ((channel_is_empty(oc) && !oc->to_forward) ||
!sc_state_in(sc->state, SC_SB_EST))))) { !sc_state_in(sc->state, SC_SB_EST))))) {
@ -1127,7 +1127,7 @@ static void sc_notify(struct stconn *sc)
/* update OC timeouts and wake the other side up if it's waiting for room */ /* update OC timeouts and wake the other side up if it's waiting for room */
if (oc->flags & (CF_WRITE_EVENT|CF_WRITE_ERROR)) { if (oc->flags & (CF_WRITE_EVENT|CF_WRITE_ERROR)) {
if ((oc->flags & (CF_SHUTW|CF_WRITE_EVENT)) == CF_WRITE_EVENT && if (!(oc->flags & CF_WRITE_ERROR) &&
!channel_is_empty(oc)) !channel_is_empty(oc))
if (tick_isset(oc->wex)) if (tick_isset(oc->wex))
oc->wex = tick_add_ifset(now_ms, oc->wto); oc->wex = tick_add_ifset(now_ms, oc->wto);

View File

@ -5022,7 +5022,7 @@ static int cli_io_handler_table(struct appctx *appctx)
* data though. * data though.
*/ */
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) { if (unlikely(sc_ic(sc)->flags & CF_SHUTW)) {
/* in case of abort, remove any refcount we might have set on an entry */ /* in case of abort, remove any refcount we might have set on an entry */
if (ctx->state == STATE_DUMP) { if (ctx->state == STATE_DUMP) {
stksess_kill_if_expired(ctx->t, ctx->entry, 1); stksess_kill_if_expired(ctx->t, ctx->entry, 1);

View File

@ -1782,7 +1782,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
*/ */
if (!((req->flags | res->flags) & if (!((req->flags | res->flags) &
(CF_SHUTR|CF_READ_EVENT|CF_READ_TIMEOUT|CF_SHUTW| (CF_SHUTR|CF_READ_EVENT|CF_READ_TIMEOUT|CF_SHUTW|
CF_WRITE_EVENT|CF_WRITE_ERROR|CF_WRITE_TIMEOUT)) && CF_WRITE_EVENT|CF_WRITE_TIMEOUT)) &&
!(s->flags & SF_CONN_EXP) && !(s->flags & SF_CONN_EXP) &&
!((sc_ep_get(scf) | scb->flags) & SE_FL_ERROR) && !((sc_ep_get(scf) | scb->flags) & SE_FL_ERROR) &&
((s->pending_events & TASK_WOKEN_ANY) == TASK_WOKEN_TIMER)) { ((s->pending_events & TASK_WOKEN_ANY) == TASK_WOKEN_TIMER)) {
@ -3626,7 +3626,7 @@ static int cli_io_handler_dump_sess(struct appctx *appctx)
goto done; goto done;
} }
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) { if (unlikely(sc_ic(sc)->flags & CF_SHUTW)) {
/* If we're forced to shut down, we might have to remove our /* If we're forced to shut down, we might have to remove our
* reference to the last stream being dumped. * reference to the last stream being dumped.
*/ */