From b4e2ea4db36d11a25245220736ee009e87b7c71b Mon Sep 17 00:00:00 2001 From: TreeHunter <60896014+TreeHunter9@users.noreply.github.com> Date: Fri, 10 Jan 2025 09:30:26 +0300 Subject: [PATCH] Fix race in shutdown thread start (#8380) Previously we assign value to shutdownSemaphore after shutdownThread is started, where it is already needed. So we can have situation where shutdownThread instantly leaving due to shutdownSemaphore == nullptr, and we are left with a server that can only be stopped with kill -9. Co-authored-by: Artyom Ivanov --- src/yvalve/why.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yvalve/why.cpp b/src/yvalve/why.cpp index cc722930c2..2aff649f03 100644 --- a/src/yvalve/why.cpp +++ b/src/yvalve/why.cpp @@ -831,11 +831,11 @@ private: explicit CtrlCHandler(MemoryPool& p) : ShutdownInit(p) { + shutdownSemaphore = &semaphore; Thread::start(shutdownThread, 0, 0, &handle); procInt = ISC_signal(SIGINT, handlerInt, 0); procTerm = ISC_signal(SIGTERM, handlerTerm, 0); - shutdownSemaphore = &semaphore; } ~CtrlCHandler()