From 62bf7a4809d37ff09ad256a3eaca977bae9284e7 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Tue, 9 May 2023 20:02:24 +0000 Subject: [PATCH] runtime: hide trace.shutdown behind traceShuttingDown Change-Id: I0b123e65f40570caeee611679d80dc27034d5a52 Reviewed-on: https://go-review.googlesource.com/c/go/+/494183 Run-TryBot: Michael Knyszek TryBot-Result: Gopher Robot Reviewed-by: Michael Pratt Auto-Submit: Michael Knyszek --- src/runtime/proc.go | 4 ++-- src/runtime/trace.go | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 3df0f84b3f..2c8750a5fe 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -2501,7 +2501,7 @@ func handoffp(pp *p) { return } // if there's trace work to do, start it straight away - if (traceEnabled() || trace.shutdown) && traceReaderAvailable() != nil { + if (traceEnabled() || traceShuttingDown()) && traceReaderAvailable() != nil { startm(pp, false, false) return } @@ -2747,7 +2747,7 @@ top: now, pollUntil, _ := checkTimers(pp, 0) // Try to schedule the trace reader. - if traceEnabled() || trace.shutdown { + if traceEnabled() || traceShuttingDown() { gp := traceReader() if gp != nil { casgstatus(gp, _Gwaiting, _Grunnable) diff --git a/src/runtime/trace.go b/src/runtime/trace.go index 64314f62e8..a89c407a8a 100644 --- a/src/runtime/trace.go +++ b/src/runtime/trace.go @@ -211,6 +211,11 @@ func traceEnabled() bool { return trace.enabled } +// traceShuttingDown returns true if the trace is currently shutting down. +func traceShuttingDown() bool { + return trace.shutdown +} + // StartTrace enables tracing for the current process. // While tracing, the data will be buffered and available via ReadTrace. // StartTrace returns an error if tracing is already enabled. -- 2.48.1