nghttpd: Cache date by comparing ev_now

This commit is contained in:
Tatsuhiro Tsujikawa 2015-01-15 23:27:52 +09:00
parent 5d204fc3aa
commit a08ce38bcf
1 changed files with 0 additions and 15 deletions

View File

@ -1329,20 +1329,9 @@ void worker_acceptcb(struct ev_loop *loop, ev_async *w, int revents) {
} }
} // namespace } // namespace
namespace {
void refresh_cb(struct ev_loop *loop, ev_timer *w, int revents) {
auto sessions = static_cast<Sessions *>(w->data);
sessions->update_cached_date();
}
} // namespace
namespace { namespace {
void run_worker(Worker *worker) { void run_worker(Worker *worker) {
auto loop = worker->sessions->get_loop(); auto loop = worker->sessions->get_loop();
ev_timer w;
ev_timer_init(&w, refresh_cb, 0., 1.);
w.data = worker->sessions.get();
ev_timer_again(loop, &w);
worker->sessions->update_cached_date(); worker->sessions->update_cached_date();
ev_run(loop, 0); ev_run(loop, 0);
@ -1672,11 +1661,7 @@ int HttpServer::run() {
return -1; return -1;
} }
ev_timer refresh_timer;
ev_timer_init(&refresh_timer, refresh_cb, 0., 1.);
refresh_timer.data = &sessions;
if (config_->num_worker == 1) { if (config_->num_worker == 1) {
ev_timer_again(loop, &refresh_timer);
sessions.update_cached_date(); sessions.update_cached_date();
} }