MEDIUM: stream: No longer use TASK_F_UEVT* to shut a stream down

Thanks to the previous patch, it is now possible to explicitly rely on
stream's events to shut it down. The right event is set in
stream_shutdown(), before waking up the stream, via an atomic operation. In
process_stream(), this event will be handled as expected.

Thus, TASK_F_UEVT* are no longer used, but not removed since still usable
for other tasks.

This patch depends on "MEDIUM: stream: Map task wake up reasons to dedicated
stream events".
This commit is contained in:
Christopher Faulet 2025-01-27 19:11:02 +01:00
parent 6048460102
commit 36d151dc10
2 changed files with 22 additions and 19 deletions

View File

@ -386,24 +386,25 @@ static inline int stream_check_conn_timeout(struct stream *s)
}
/* Wake a stream up for shutdown by sending it an event. The stream must be
* locked one way or another so that it cannot leave (i.e. when inspecting
* a locked list or under thread isolation). Process_stream() will recognize
* the message and complete the job. <why> only supports SF_ERR_DOWN (mapped
* to UEVT1), SF_ERR_KILLED (mapped to UEVT2) and SF_ERR_UP (mapped to UEVT3).
* Other values will just trigger TASK_WOKEN_OTHER.
* The stream handler will first call function stream_shutdown_self() on wakeup
* to complete the notification.
* locked one way or another so that it cannot leave (i.e. when inspecting a
* locked list or under thread isolation). Process_stream() will recognize the
* message and complete the job. <why> only supports SF_ERR_DOWN (mapped to
* STRM_EVT_SHUT_SRV_DOWN), SF_ERR_KILLED (mapped to STRM_EVT_KILLED) and
* SF_ERR_UP (mapped to STRM_EVT_SHUT_SRV_UP). Other values will just be
* ignored. The stream is woken up with TASK_WOKEN_OTHER reason. The stream
* handler will first call function stream_shutdown_self() on wakeup to complete
* the notification.
*/
static inline void stream_shutdown(struct stream *s, int why)
{
task_wakeup(s->task, TASK_WOKEN_OTHER |
((why == SF_ERR_DOWN) ? TASK_F_UEVT1 :
(why == SF_ERR_KILLED) ? TASK_F_UEVT2 :
(why == SF_ERR_UP) ? TASK_F_UEVT3 :
0));
HA_ATOMIC_OR(&s->new_events, ((why == SF_ERR_DOWN) ? STRM_EVT_SHUT_SRV_DOWN :
(why == SF_ERR_KILLED) ? STRM_EVT_KILLED :
(why == SF_ERR_UP) ? STRM_EVT_SHUT_SRV_UP :
0));
task_wakeup(s->task, TASK_WOKEN_OTHER);
}
/* Map task states to stream events. TASK_WOKEN_* and TASK_F_UEVT* are mapped on
/* Map task states to stream events. TASK_WOKEN_* are mapped on
* STRM_EVT_*. Not all states/flags are mapped, only those explicitly used by
* the stream.
*/

View File

@ -1703,12 +1703,14 @@ void stream_update_timings(struct task *t, uint64_t lat, uint64_t cpu)
* and each function is called only if at least another function has changed at
* least one flag it is interested in.
*
* This task handler understands a few wake up reasons:
* - TASK_WOKEN_MSG forces analysers to be re-evaluated
* - TASK_WOKEN_OTHER+TASK_F_UEVT1 shuts the stream down on server down
* - TASK_WOKEN_OTHER+TASK_F_UEVT2 shuts the stream down on active kill
* - TASK_WOKEN_OTHER+TASK_F_UEVT3 shuts the stream down because a preferred backend became available
* - TASK_WOKEN_OTHER alone has no effect
* TASK_WOKEN_* wake up reasons are mapped to STRM_EVT_*
*
* This task handler understands a few wake up events:
* - STRM_EVT_MSG forces analysers to be re-evaluated
* - STRM_EVT_TIMER forces timers to be re-evaluated
* - STRM_EVT_SHUT_SRV_DOWN shuts the stream down on server down
* - STRM_EVT_KILLED shuts the stream down on active kill
* - STRM_EVT_SHUT_SRV_UP shuts the stream down because a preferred backend became available
*/
struct task *process_stream(struct task *t, void *context, unsigned int state)
{