}
/* 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.
*/
* 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)
{