Adhoc: Fix shutdown hanging when it comes right after adhoc init

The friend finder thread set friendFinderRunning itself, after a DNS
lookup of the adhoc server. A shutdown in that window cleared the flag
first; the thread then set it again, looped forever, and the join in
NetAdhocctl_Term() never returned. Gods Eater Burst hit this in about one
headless run in six. The flag is now set before the thread is created,
and a finished thread is joined before a new one replaces it, which
would otherwise call std::terminate.

The built-in adhoc server thread had the same race, behind its check for
an existing server, and gets the same fix.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-09-29 11:58:42 -06:00
1 parent 806618f9a3
commit 2cd84012d0
3 files changed
+14 -6

No files matched your search

+1 -3
View File
@@ -1865,9 +1865,7 @@ int create_listen_socket(uint16_t port)
*/
int server_loop(int server)
{
// Set Running Status
//_status = 1;
adhocServerRunning = true;
// adhocServerRunning was set by whoever started the thread, and is cleared to stop it.
// Create Empty Status Logfile
update_status();