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.

(Backported a8ea479 from master.)
  • Loading branch information
irydacea committed Oct 10, 2014
1 parent 29c77cb commit 52337f9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/campaign_server/campaign_server.cpp
Expand Up @@ -360,7 +360,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 @@ -372,9 +374,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 52337f9

Please sign in to comment.