From 974da9f8a41e53c9d4227a27c2a64c00c53644cc Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 30 Mar 2022 15:30:03 +0200 Subject: [PATCH] MINOR: stream-int: Remove SI_FL_DONT_WAKE to rely on CS flags instead Flag to not wake the stream up on I/O is now handled at the conn-stream level. Thus SI_FL_DONT_WAKE stream-int flag is replaced by CS_FL_DONT_WAKE conn-stream flags. --- dev/flags/flags.c | 2 +- include/haproxy/conn_stream-t.h | 1 + include/haproxy/stream_interface-t.h | 1 - src/cli.c | 3 ++- src/stream.c | 16 ++++++++-------- src/stream_interface.c | 10 +++++----- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/dev/flags/flags.c b/dev/flags/flags.c index 8317b7550..6a8b5ab36 100644 --- a/dev/flags/flags.c +++ b/dev/flags/flags.c @@ -219,6 +219,7 @@ void show_cs_flags(unsigned int f) printf("0\n"); return; } + SHOW_FLAG(f, CS_FL_DONT_WAKE); SHOW_FLAG(f, CS_FL_NOLINGER); SHOW_FLAG(f, CS_FL_NOHALF); SHOW_FLAG(f, CS_FL_ADDR_FROM_SET); @@ -267,7 +268,6 @@ void show_si_flags(unsigned int f) SHOW_FLAG(f, SI_FL_WAIT_DATA); SHOW_FLAG(f, SI_FL_ISBACK); - SHOW_FLAG(f, SI_FL_DONT_WAKE); SHOW_FLAG(f, SI_FL_INDEP_STR); SHOW_FLAG(f, SI_FL_SRC_ADDR); SHOW_FLAG(f, SI_FL_WANT_GET); diff --git a/include/haproxy/conn_stream-t.h b/include/haproxy/conn_stream-t.h index 877bace13..60cd9fa6d 100644 --- a/include/haproxy/conn_stream-t.h +++ b/include/haproxy/conn_stream-t.h @@ -85,6 +85,7 @@ enum { CS_FL_NOLINGER = 0x00000008, /* may close without lingering. One-shot. */ CS_FL_NOHALF = 0x00000010, /* no half close, close both sides at once */ + CS_FL_DONT_WAKE = 0x00000020, /* resync in progress, don't wake up */ }; /* cs_shutr() modes */ diff --git a/include/haproxy/stream_interface-t.h b/include/haproxy/stream_interface-t.h index ebd9d3515..6ffc3d4c6 100644 --- a/include/haproxy/stream_interface-t.h +++ b/include/haproxy/stream_interface-t.h @@ -86,7 +86,6 @@ enum { /* unused: 0x00000001, 0x00000002 */ SI_FL_WAIT_DATA = 0x00000008, /* stream-int waits for more outgoing data to send */ SI_FL_ISBACK = 0x00000010, /* 0 for front-side SI, 1 for back-side */ - SI_FL_DONT_WAKE = 0x00000020, /* resync in progress, don't wake up */ SI_FL_INDEP_STR = 0x00000040, /* independent streams = don't update rex on write */ SI_FL_SRC_ADDR = 0x00001000, /* get the source ip/port with getsockname */ /* unused: 0x00000200 */ diff --git a/src/cli.c b/src/cli.c index 4d0e293fc..f55999e03 100644 --- a/src/cli.c +++ b/src/cli.c @@ -2768,7 +2768,8 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit) cs_si(s->csb)->state = cs_si(s->csb)->prev_state = SI_ST_INI; cs_si(s->csb)->err_type = SI_ET_NONE; - cs_si(s->csb)->flags &= SI_FL_ISBACK | SI_FL_DONT_WAKE; /* we're in the context of process_stream */ + cs_si(s->csb)->flags &= SI_FL_ISBACK; /* we're in the context of process_stream */ + s->csb->flags &= CS_FL_ISBACK | CS_FL_DONT_WAKE; /* we're in the context of process_stream */ s->req.flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WROTE_DATA); s->res.flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA|CF_READ_NULL); s->flags &= ~(SF_DIRECT|SF_ASSIGNED|SF_ADDR_SET|SF_BE_ASSIGNED|SF_FORCE_PRST|SF_IGNORE_PRST); diff --git a/src/stream.c b/src/stream.c index a42c8968f..c2e0b24dd 100644 --- a/src/stream.c +++ b/src/stream.c @@ -1616,9 +1616,9 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) rqf_last = req->flags & ~CF_MASK_ANALYSER; rpf_last = res->flags & ~CF_MASK_ANALYSER; - /* we don't want the stream interface functions to recursively wake us up */ - si_f->flags |= SI_FL_DONT_WAKE; - si_b->flags |= SI_FL_DONT_WAKE; + /* we don't want the conn-stream functions to recursively wake us up */ + s->csf->flags |= CS_FL_DONT_WAKE; + s->csb->flags |= CS_FL_DONT_WAKE; /* update pending events */ s->pending_events |= (state & TASK_WOKEN_ANY); @@ -1675,8 +1675,8 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) !(s->flags & SF_CONN_EXP) && !((s->csf->endp->flags | s->csb->flags) & CS_EP_ERROR) && ((s->pending_events & TASK_WOKEN_ANY) == TASK_WOKEN_TIMER)) { - si_f->flags &= ~SI_FL_DONT_WAKE; - si_b->flags &= ~SI_FL_DONT_WAKE; + s->csf->flags &= ~CS_FL_DONT_WAKE; + s->csb->flags &= ~CS_FL_DONT_WAKE; goto update_exp_and_leave; } } @@ -2393,8 +2393,8 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) goto resync_request; /* we're interested in getting wakeups again */ - si_f->flags &= ~SI_FL_DONT_WAKE; - si_b->flags &= ~SI_FL_DONT_WAKE; + s->csf->flags &= ~CS_FL_DONT_WAKE; + s->csb->flags &= ~CS_FL_DONT_WAKE; /* This is needed only when debugging is enabled, to indicate * client-side or server-side close. Please note that in the unlikely @@ -2448,7 +2448,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) s->pending_events = 0; update_exp_and_leave: - /* Note: please ensure that if you branch here you disable SI_FL_DONT_WAKE */ + /* Note: please ensure that if you branch here you disable CS_FL_DONT_WAKE */ t->expire = tick_first((tick_is_expired(t->expire, now_ms) ? 0 : t->expire), tick_first(tick_first(req->rex, req->wex), tick_first(res->rex, res->wex))); diff --git a/src/stream_interface.c b/src/stream_interface.c index 2c196ce44..66f4980ce 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -188,7 +188,7 @@ static void stream_int_shutr(struct stream_interface *si) } /* note that if the task exists, it must unregister itself once it runs */ - if (!(si->flags & SI_FL_DONT_WAKE)) + if (!(si->cs->flags & CS_FL_DONT_WAKE)) task_wakeup(si_task(si), TASK_WOKEN_IO); } @@ -246,7 +246,7 @@ static void stream_int_shutw(struct stream_interface *si) } /* note that if the task exists, it must unregister itself once it runs */ - if (!(si->flags & SI_FL_DONT_WAKE)) + if (!(si->cs->flags & CS_FL_DONT_WAKE)) task_wakeup(si_task(si), TASK_WOKEN_IO); } @@ -266,7 +266,7 @@ static void stream_int_chk_rcv(struct stream_interface *si) else { /* (re)start reading */ tasklet_wakeup(si->wait_event.tasklet); - if (!(si->flags & SI_FL_DONT_WAKE)) + if (!(si->cs->flags & CS_FL_DONT_WAKE)) task_wakeup(si_task(si), TASK_WOKEN_IO); } } @@ -294,7 +294,7 @@ static void stream_int_chk_snd(struct stream_interface *si) if (!tick_isset(oc->wex)) oc->wex = tick_add_ifset(now_ms, oc->wto); - if (!(si->flags & SI_FL_DONT_WAKE)) + if (!(si->cs->flags & CS_FL_DONT_WAKE)) task_wakeup(si_task(si), TASK_WOKEN_IO); } @@ -1237,7 +1237,7 @@ static void stream_int_chk_snd_conn(struct stream_interface *si) ((channel_is_empty(oc) && !oc->to_forward) || !si_state_in(si->state, SI_SB_EST))))) { out_wakeup: - if (!(si->flags & SI_FL_DONT_WAKE)) + if (!(si->cs->flags & CS_FL_DONT_WAKE)) task_wakeup(si_task(si), TASK_WOKEN_IO); } }