From faa0406b5458ca4c4b3d603774f82eb8de600eb4 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 21 Mar 2023 20:39:46 +0200 Subject: [PATCH 24/24] Fix threaded saving of the game on signal Wait for the saving thread to finish before quitting the program. Reported by alain_bkr See osdn #47540 Signed-off-by: Marko Lindqvist --- server/civserver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/civserver.c b/server/civserver.c index f879e0e5a4..90323b7c3d 100644 --- a/server/civserver.c +++ b/server/civserver.c @@ -60,6 +60,9 @@ #include "sernet.h" #include "srv_main.h" +/* server/savegame */ +#include "savemain.h" + #ifdef GENERATING_MAC static void Mac_options(int argc); /* don't need argv */ #endif @@ -72,11 +75,12 @@ static void Mac_options(int argc); /* don't need argv */ #define save_and_exit(sig) \ if (S_S_RUNNING == server_state()) { \ save_game_auto(#sig, AS_INTERRUPT); \ + save_system_close(); \ } \ exit(EXIT_SUCCESS); /**********************************************************************//** - This function is called when a SIGINT (ctrl-c) is received. It will exit + This function is called when a SIGINT (ctrl-c) is received. It will exit only if two SIGINTs are received within a second. **************************************************************************/ static void signal_handler(int sig) -- 2.39.2