]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: trace: make sure to always stop the locking when stopping or pausing
authorWilly Tarreau <w@1wt.eu>
Tue, 20 Aug 2019 16:57:48 +0000 (18:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 22 Aug 2019 18:21:00 +0000 (20:21 +0200)
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.

src/trace.c

index eec34779bdcf9fc102f614662cec79647ef25fed..77837021491878b7d9bf46772d8516ea80150fd4 100644 (file)
@@ -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;
                }