]> git.pond.sub.org Git - empserver/commitdiff
Fix player thread race with update_init()
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 28 Apr 2009 21:06:16 +0000 (23:06 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 30 Nov 2009 18:43:47 +0000 (19:43 +0100)
start_server() creates the thread running player_accept() before it
calls update_init().  However, update_init() initializes stuff used to
player threads: update_time[] and play_lock.  In theory, a player
thread could start before that, and crash when taking the
uninitialized play_lock.

Delay starting that tread until after update_init().

src/server/main.c

index 336eb6a65d1e4c408b910b9271f4481bbdce08f8..022f32ab86f1fa69e6836e3f75335c169aa9bf65 100644 (file)
@@ -375,10 +375,9 @@ start_server(int flags)
     if (journal_startup() < 0)
        exit(1);
 
-    empth_create(player_accept, 50 * 1024, flags, "AcceptPlayers", NULL);
-
     market_init();
     update_init();
+    empth_create(player_accept, 50 * 1024, flags, "AcceptPlayers", NULL);
 }
 
 /*