diff options
author | Erik Andersson <erik@packy.se> | 2016-11-22 23:51:17 +0100 |
---|---|---|
committer | Erik Andersson <erik@packy.se> | 2016-11-22 23:51:17 +0100 |
commit | 09abe2a091672f45ccacd6a90d0f3872b6cb6a00 (patch) | |
tree | 10a034ecdb8f876fb3829ef7eafa4c85194c82d3 /src/schedule.cpp | |
parent | 6addd793e745d6a2a65b66249c4f36e763e142e8 (diff) | |
download | ocelot-09abe2a091672f45ccacd6a90d0f3872b6cb6a00.zip ocelot-09abe2a091672f45ccacd6a90d0f3872b6cb6a00.tar.gz ocelot-09abe2a091672f45ccacd6a90d0f3872b6cb6a00.tar.bz2 |
Ocelot v0.6 (r1)v0.6-r1
Diffstat (limited to 'src/schedule.cpp')
-rw-r--r-- | src/schedule.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/schedule.cpp b/src/schedule.cpp index b33d1c8..eb79b4b 100644 --- a/src/schedule.cpp +++ b/src/schedule.cpp @@ -6,7 +6,7 @@ #include "schedule.h" -schedule::schedule(connection_mother * mother_obj, worker* worker_obj, config* conf_obj, mysql * db_obj) : mother(mother_obj), work(worker_obj), conf(conf_obj), db(db_obj) { +schedule::schedule(connection_mother * mother_obj, worker* worker_obj, config* conf_obj, mysql * db_obj, site_comm * sc_obj) : mother(mother_obj), work(worker_obj), conf(conf_obj), db(db_obj), sc(sc_obj) { counter = 0; last_opened_connections = 0; @@ -15,13 +15,13 @@ schedule::schedule(connection_mother * mother_obj, worker* worker_obj, config* c //---------- Schedule - gets called every schedule_interval seconds void schedule::handle(ev::timer &watcher, int events_flags) { - if(counter % 20 == 0) { + if (counter % 20 == 0) { std::cout << "Schedule run #" << counter << " - open: " << mother->get_open_connections() << ", opened: " << mother->get_opened_connections() << ", speed: " << ((mother->get_opened_connections()-last_opened_connections)/conf->schedule_interval) << "/s" << std::endl; } - if ((work->get_status() == CLOSING) && db->all_clear()) { + if ((work->get_status() == CLOSING) && db->all_clear() && sc->all_clear()) { std::cout << "all clear, shutting down" << std::endl; exit(0); } @@ -29,10 +29,11 @@ void schedule::handle(ev::timer &watcher, int events_flags) { last_opened_connections = mother->get_opened_connections(); db->flush(); + sc->flush_tokens(); time_t cur_time = time(NULL); - if(cur_time > next_reap_peers) { + if (cur_time > next_reap_peers) { work->reap_peers(); next_reap_peers = cur_time + conf->reap_peers_interval; } |