mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-16 18:31:32 +00:00
campaignd: Replace write_config() scheduling mechanism
Check time() deltas instead of incrementing a counter variable forever. This should allow to extract a bit of the run() logic into a separate method later.
This commit is contained in:
parent
deea32f9a5
commit
a8ea4796a0
@ -361,7 +361,9 @@ void server::run()
|
||||
|
||||
network::connection sock = 0;
|
||||
|
||||
for(int increment = 0;; ++increment)
|
||||
time_t last_ts = time(NULL);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
try {
|
||||
std::string admin_cmd;
|
||||
@ -373,9 +375,12 @@ void server::run()
|
||||
break;
|
||||
}
|
||||
}
|
||||
//write config to disk every ten minutes
|
||||
if((increment%(60*10*50)) == 0) {
|
||||
|
||||
const time_t cur_ts = time(NULL);
|
||||
// Write config to disk every ten minutes.
|
||||
if(cur_ts - last_ts >= 60) {
|
||||
write_config();
|
||||
last_ts = cur_ts;
|
||||
}
|
||||
|
||||
network::process_send_queue();
|
||||
|
Loading…
x
Reference in New Issue
Block a user