From 55be3c7105c1b925bbddf2d822ec3164eceb2243 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 20 Jun 2016 20:40:06 +0200 Subject: [PATCH] update server: Move update_running from server/ to update/ update.h is a more logical home for update_running than server.h. Move the definition and the assignments along, from server/update.c to lib/update/main.c. Signed-off-by: Markus Armbruster --- include/server.h | 1 - include/update.h | 1 + src/lib/subs/land.c | 1 - src/lib/subs/plane.c | 1 - src/lib/subs/pr.c | 2 +- src/lib/subs/rej.c | 2 +- src/lib/subs/sect.c | 1 - src/lib/subs/ship.c | 1 - src/lib/subs/wu.c | 2 +- src/lib/update/main.c | 8 ++++++++ src/server/update.c | 8 -------- 11 files changed, 12 insertions(+), 16 deletions(-) diff --git a/include/server.h b/include/server.h index 1448d144..0ebd78be 100644 --- a/include/server.h +++ b/include/server.h @@ -40,7 +40,6 @@ extern int shutdown_pending; extern empth_rwlock_t *update_lock; extern empth_rwlock_t *shutdown_lock; -extern int update_running; extern time_t update_time[UPDATE_TIME_LEN]; void market_init(void); diff --git a/include/update.h b/include/update.h index 7a159f4e..2c76540f 100644 --- a/include/update.h +++ b/include/update.h @@ -74,6 +74,7 @@ struct budget { }; /* main.c */ +extern int update_running; extern struct budget nat_budget[MAXNOC]; /* age.c */ diff --git a/src/lib/subs/land.c b/src/lib/subs/land.c index 4d187006..f9805583 100644 --- a/src/lib/subs/land.c +++ b/src/lib/subs/land.c @@ -40,7 +40,6 @@ #include "optlist.h" #include "player.h" #include "prototypes.h" -#include "server.h" #include "unit.h" #include "update.h" diff --git a/src/lib/subs/plane.c b/src/lib/subs/plane.c index 1c28368f..517c9b5b 100644 --- a/src/lib/subs/plane.c +++ b/src/lib/subs/plane.c @@ -41,7 +41,6 @@ #include "plane.h" #include "player.h" #include "prototypes.h" -#include "server.h" #include "unit.h" #include "update.h" diff --git a/src/lib/subs/pr.c b/src/lib/subs/pr.c index db8943ac..ab7922d8 100644 --- a/src/lib/subs/pr.c +++ b/src/lib/subs/pr.c @@ -60,7 +60,7 @@ #include "player.h" #include "proto.h" #include "prototypes.h" -#include "server.h" +#include "update.h" #include "xy.h" static void pr_player(struct player *pl, int id, char *buf); diff --git a/src/lib/subs/rej.c b/src/lib/subs/rej.c index 398996d5..1ac45846 100644 --- a/src/lib/subs/rej.c +++ b/src/lib/subs/rej.c @@ -39,7 +39,7 @@ #include "optlist.h" #include "player.h" #include "prototypes.h" -#include "server.h" +#include "update.h" void setrel(natid us, natid them, int rel) diff --git a/src/lib/subs/sect.c b/src/lib/subs/sect.c index a53ee52b..8bc4056f 100644 --- a/src/lib/subs/sect.c +++ b/src/lib/subs/sect.c @@ -44,7 +44,6 @@ #include "player.h" #include "prototypes.h" #include "sect.h" -#include "server.h" #include "update.h" #include "xy.h" diff --git a/src/lib/subs/ship.c b/src/lib/subs/ship.c index 3c75e84c..cfd4bced 100644 --- a/src/lib/subs/ship.c +++ b/src/lib/subs/ship.c @@ -40,7 +40,6 @@ #include "optlist.h" #include "player.h" #include "prototypes.h" -#include "server.h" #include "ship.h" #include "unit.h" #include "update.h" diff --git a/src/lib/subs/wu.c b/src/lib/subs/wu.c index 6e4768fb..d40af3e7 100644 --- a/src/lib/subs/wu.c +++ b/src/lib/subs/wu.c @@ -43,8 +43,8 @@ #include "optlist.h" #include "player.h" #include "prototypes.h" -#include "server.h" #include "tel.h" +#include "update.h" static struct telstr last_tel[MAXNOC]; diff --git a/src/lib/update/main.c b/src/lib/update/main.c index e71da436..459232c8 100644 --- a/src/lib/update/main.c +++ b/src/lib/update/main.c @@ -46,6 +46,12 @@ #include "unit.h" #include "update.h" +/* + * Update is running. + * Can be used to suppress messages, or direct them to bulletins. + */ +int update_running; + struct budget nat_budget[MAXNOC]; void @@ -57,6 +63,7 @@ update_main(void) int i; struct natstr *np; + update_running = 1; logerror("production update (%d etus)", etu); getrusage(RUSAGE_SELF, &rus1); game_record_update(time(NULL)); @@ -134,4 +141,5 @@ update_main(void) - (rus1.ru_utime.tv_sec + rus1.ru_utime.tv_usec / 1e6), rus2.ru_stime.tv_sec + rus2.ru_stime.tv_usec / 1e6 - (rus1.ru_stime.tv_sec + rus1.ru_stime.tv_usec / 1e6)); + update_running = 0; } diff --git a/src/server/update.c b/src/server/update.c index d6caf614..195eaa1a 100644 --- a/src/server/update.c +++ b/src/server/update.c @@ -50,12 +50,6 @@ #include "prototypes.h" #include "server.h" -/* - * Update is running. - * Can be used to suppress messages, or direct them to bulletins. - */ -int update_running; - static time_t update_schedule_anchor; static int update_wanted; @@ -205,9 +199,7 @@ update_run(void) return; } } - update_running = 1; update_main(); - update_running = 0; empth_rwlock_unlock(update_lock); }