Skip to content

Commit 0457815

Browse files
author
Artyom Ivanov
committed
Fix race in shutdown thread start
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.
1 parent 81bba14 commit 0457815

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/yvalve/why.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,11 +831,11 @@ class ShutdownInit
831831
explicit CtrlCHandler(MemoryPool& p)
832832
: ShutdownInit(p)
833833
{
834+
shutdownSemaphore = &semaphore;
834835
Thread::start(shutdownThread, 0, 0, &handle);
835836

836837
procInt = ISC_signal(SIGINT, handlerInt, 0);
837838
procTerm = ISC_signal(SIGTERM, handlerTerm, 0);
838-
shutdownSemaphore = &semaphore;
839839
}
840840

841841
~CtrlCHandler()

0 commit comments

Comments
 (0)