unsigned int nb_tasks; /* number of tasks allocated on this thread */
uint8_t tl_class_mask; /* bit mask of non-empty tasklets classes */
uint8_t bufq_map; /* one bit per non-empty buffer_wq */
+ uint8_t trc_disable_ctr; /* cumulative counter to temporarily disable tracing */
- // 2 bytes hole here
+ // 1 byte hole here
unsigned int nb_rhttp_conns; /* count of current conns used for active reverse HTTP */
struct sched_activity *sched_profile_entry; /* profile entry in use by the current task/tasklet, only if sched_wake_date>0 */
return (conf & ev) ? '+' : '-';
}
+/* Temporarily disable trace using a cumulative counter. If called multiple
+ * times, the same number of resume must be used to reactivate tracing.
+ *
+ * Returns the incremented counter value or 0 if already at the maximum value.
+ */
+static inline uint8_t trace_disable(void)
+{
+ if (unlikely(th_ctx->trc_disable_ctr == UCHAR_MAX))
+ return 0;
+ return ++th_ctx->trc_disable_ctr;
+}
+
+/* Resume tracing after a temporarily disabling. It may be called several times
+ * as disable operation is cumulative.
+ */
+static inline void trace_resume(void)
+{
+ if (th_ctx->trc_disable_ctr)
+ --th_ctx->trc_disable_ctr;
+}
+
+/* Resume tracing immediately even after multiple disable operations.
+ *
+ * Returns the old counter value. Useful to reactivate trace disabling at the
+ * previous level.
+ */
+static inline uint8_t trace_force_resume(void)
+{
+ const int val = th_ctx->trc_disable_ctr;
+ th_ctx->trc_disable_ctr = 0;
+ return val;
+}
+
+/* Set trace disabling counter to <disable>. Mostly useful with the value
+ * returned from trace_force_resume() to restore tracing disable status to the
+ * previous level.
+ */
+static inline void trace_reset_disable(uint8_t disable)
+{
+ th_ctx->trc_disable_ctr = disable;
+}
+
#endif /* _HAPROXY_TRACE_H */
/*
/* in case we also follow another one (e.g. session) */
origin = HA_ATOMIC_LOAD(&src->follow);
+ /* Trace can be temporarily disabled via trace_disable(). */
if (likely(src->state == TRACE_STATE_STOPPED) && !origin)
return 0;
+ if (th_ctx->trc_disable_ctr)
+ return 0;
+
/* check that at least one action is interested by this event */
if (((src->report_events | src->start_events | src->pause_events | src->stop_events) & mask) == 0)
return 0;