summaryrefslogtreecommitdiffstats
path: root/src/schedule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/schedule.cpp')
-rw-r--r--src/schedule.cpp9
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;
}