From: Willy Tarreau Date: Tue, 20 Aug 2019 16:57:48 +0000 (+0200) Subject: MINOR: trace: make sure to always stop the locking when stopping or pausing X-Git-Tag: v2.1-dev2~183 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=beadb5c823030545440a83e19b31de78194fd6f0;p=thirdparty%2Fhaproxy.git MINOR: trace: make sure to always stop the locking when stopping or pausing When we stop or pause a trace (either on a matching event or by hand), we must also stop the lock-on feature so that we don't follow any further activity on this pointer even if it is recycled. For now this is not exploited. --- diff --git a/src/trace.c b/src/trace.c index eec34779bd..7783702149 100644 --- a/src/trace.c +++ b/src/trace.c @@ -112,9 +112,11 @@ void __trace(enum trace_level level, uint64_t mask, struct trace_source *src, co end: /* check if we need to stop the trace now */ if ((src->stop_events & mask) != 0) { + HA_ATOMIC_STORE(&src->lockon_ptr, NULL); HA_ATOMIC_STORE(&src->state, TRACE_STATE_STOPPED); } else if ((src->pause_events & mask) != 0) { + HA_ATOMIC_STORE(&src->lockon_ptr, NULL); HA_ATOMIC_STORE(&src->state, TRACE_STATE_WAITING); } } @@ -222,12 +224,17 @@ static int cli_parse_trace(char **args, char *payload, struct appctx *appctx, vo if (strcmp(name, "now") == 0 && ev_ptr != &src->report_events) { HA_ATOMIC_STORE(ev_ptr, 0); - if (ev_ptr == &src->pause_events) + if (ev_ptr == &src->pause_events) { + HA_ATOMIC_STORE(&src->lockon_ptr, NULL); HA_ATOMIC_STORE(&src->state, TRACE_STATE_WAITING); - else if (ev_ptr == &src->start_events) + } + else if (ev_ptr == &src->start_events) { HA_ATOMIC_STORE(&src->state, TRACE_STATE_RUNNING); - else if (ev_ptr == &src->stop_events) + } + else if (ev_ptr == &src->stop_events) { + HA_ATOMIC_STORE(&src->lockon_ptr, NULL); HA_ATOMIC_STORE(&src->state, TRACE_STATE_STOPPED); + } return 0; }