From a3fbdaed1c363a82c314b779dbc1fd174481c35e Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 21 Mar 2023 20:42:37 +0200 Subject: [PATCH 20/20] 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/civserver.c b/server/civserver.c index 565542965f..2f48eabeb4 100644 --- a/server/civserver.c +++ b/server/civserver.c @@ -57,6 +57,7 @@ #include "aiiface.h" #include "console.h" #include "meta.h" +#include "savegame.h" #include "sernet.h" #include "srv_main.h" @@ -72,11 +73,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