Author: cazfi Date: Sat Jan 31 10:12:10 2015 New Revision: 27916 URL: http://svn.gna.org/viewcvs/freeciv?rev=27916&view=rev Log: Free timing logs on server exit
See patch #5749 Modified: branches/S2_5/server/srv_log.c branches/S2_5/server/srv_log.h branches/S2_5/server/srv_main.c Modified: branches/S2_5/server/srv_log.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/srv_log.c?rev=27916&r1=27915&r2=27916&view=diff ============================================================================== --- branches/S2_5/server/srv_log.c (original) +++ branches/S2_5/server/srv_log.c Sat Jan 31 10:12:10 2015 @@ -159,17 +159,10 @@ void timing_log_real(enum ai_timer timer, enum ai_timer_activity activity) { static int turn = -1; - int i; - - if (turn == -1) { - for (i = 0; i < AIT_LAST; i++) { - aitimer[i][0] = timer_new(TIMER_CPU, TIMER_ACTIVE); - aitimer[i][1] = timer_new(TIMER_CPU, TIMER_ACTIVE); - recursion[i] = 0; - } - } if (game.info.turn != turn) { + int i; + turn = game.info.turn; for (i = 0; i < AIT_LAST; i++) { timer_clear(aitimer[i][0]); @@ -248,3 +241,30 @@ AILOG_OUT("Citizen arrange", AIT_CITIZEN_ARRANGE); AILOG_OUT("Tech", AIT_TECH); } + +/************************************************************************** + Initialize AI timing system +**************************************************************************/ +void timing_log_init(void) +{ + int i; + + for (i = 0; i < AIT_LAST; i++) { + aitimer[i][0] = timer_new(TIMER_CPU, TIMER_ACTIVE); + aitimer[i][1] = timer_new(TIMER_CPU, TIMER_ACTIVE); + recursion[i] = 0; + } +} + +/************************************************************************** + Free AI timing system resources +**************************************************************************/ +void timing_log_free(void) +{ + int i; + + for (i = 0; i < AIT_LAST; i++) { + timer_destroy(aitimer[i][0]); + timer_destroy(aitimer[i][1]); + } +} Modified: branches/S2_5/server/srv_log.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/srv_log.h?rev=27916&r1=27915&r2=27916&view=diff ============================================================================== --- branches/S2_5/server/srv_log.h (original) +++ branches/S2_5/server/srv_log.h Sat Jan 31 10:12:10 2015 @@ -129,6 +129,9 @@ } \ } +void timing_log_init(void); +void timing_log_free(void); + void timing_log_real(enum ai_timer timer, enum ai_timer_activity activity); void timing_results_real(void); Modified: branches/S2_5/server/srv_main.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/srv_main.c?rev=27916&r1=27915&r2=27916&view=diff ============================================================================== --- branches/S2_5/server/srv_main.c (original) +++ branches/S2_5/server/srv_main.c Sat Jan 31 10:12:10 2015 @@ -114,6 +114,7 @@ #include "sernet.h" #include "settings.h" #include "spacerace.h" +#include "srv_log.h" #include "stdinhand.h" #include "techtools.h" #include "unithand.h" @@ -206,6 +207,9 @@ /* This is before ai module initializations so that if ai module * wants to use registry files, it can. */ registry_module_init(); + + /* We want this before any AI stuff */ + timing_log_init(); /* This must be before command line argument parsing. This allocates default ai, and we want that to take place before @@ -1410,6 +1414,7 @@ voting_free(); close_connections_and_socket(); rulesets_deinit(); + timing_log_free(); registry_module_close(); fc_destroy_mutex(&game.server.mutexes.city_list); free_nls(); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits