Skip to content

Commit

Permalink
campaignd: Replace write_config() scheduling mechanism
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
irydacea committed Jun 11, 2014
1 parent deea32f commit a8ea479
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/campaign_server/campaign_server.cpp
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit a8ea479

Please sign in to comment.