From b31ed0acd1c5e20281556de66fa52d797c156826 Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Mon, 13 Jan 2025 15:23:42 +0100 Subject: [PATCH] utils: add ?force=true hint for CPU profiler (#10368) This makes it less annoying to try to take a CPU profile when a continuous profile is already running. --- libs/utils/src/http/endpoint.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/utils/src/http/endpoint.rs b/libs/utils/src/http/endpoint.rs index ca65c39ad6..9f38373ca0 100644 --- a/libs/utils/src/http/endpoint.rs +++ b/libs/utils/src/http/endpoint.rs @@ -372,7 +372,11 @@ pub async fn profile_cpu_handler(req: Request) -> Result, A match PROFILE_LOCK.try_lock() { Ok(lock) => break lock, Err(_) if force => PROFILE_CANCEL.notify_waiters(), - Err(_) => return Err(ApiError::Conflict("profiler already running".into())), + Err(_) => { + return Err(ApiError::Conflict( + "profiler already running (use ?force=true to cancel it)".into(), + )) + } } tokio::time::sleep(Duration::from_millis(1)).await; // don't busy-wait };