Don't stop passing the accept lock even when workers are very busy.

If a worker reached worker_max_connections and it was its turn to
grab the accept lock it would've gotten stuck and no new connections
would be handled even if other workers would be less busy.

Instead, we now skip the lock if we're too busy and pass it along
in the hopes other workers are less busy.
This commit is contained in:
Joris Vink 2013-11-27 23:02:15 +01:00
parent 6f311a06cf
commit 79aea48757
2 changed files with 17 additions and 4 deletions

View File

@ -186,6 +186,7 @@ struct kore_worker {
u_int16_t load;
pid_t pid;
u_int8_t has_lock;
u_int8_t busy_warn;
u_int16_t accepted;
u_int16_t accept_treshold;
struct kore_module_handle *active_hdlr;

View File

@ -115,6 +115,7 @@ kore_worker_spawn(u_int16_t id, u_int16_t cpu)
kw->load = 0;
kw->accepted = 0;
kw->has_lock = 0;
kw->busy_warn = 0;
kw->active_hdlr = NULL;
kw->pid = fork();
@ -232,8 +233,7 @@ kore_worker_entry(struct kore_worker *kw)
sig_recv = 0;
}
if (!worker->has_lock &&
(worker_active_connections < worker_max_connections))
if (!worker->has_lock)
kore_worker_acceptlock_obtain();
kore_platform_event_wait();
@ -411,8 +411,20 @@ kore_worker_acceptlock_obtain(void)
}
if (worker_trylock()) {
worker->has_lock = 1;
kore_platform_enable_accept();
if (worker_active_connections >= worker_max_connections) {
worker->accepted = 0;
worker_unlock();
if (worker->busy_warn == 0) {
kore_log(LOG_NOTICE,
"skipping accept lock, too busy");
worker->busy_warn = 1;
}
} else {
worker->has_lock = 1;
worker->busy_warn = 0;
kore_platform_enable_accept();
}
}
}