mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
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:
parent
6048460102
commit
36d151dc10
@ -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.
|
||||
*/
|
||||
|
14
src/stream.c
14
src/stream.c
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user