mirror of
https://github.com/jorisvink/kore
synced 2025-03-10 04:59:02 -04:00
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:
parent
6f311a06cf
commit
79aea48757
@ -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;
|
||||
|
16
src/worker.c
16
src/worker.c
@ -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,10 +411,22 @@ kore_worker_acceptlock_obtain(void)
|
||||
}
|
||||
|
||||
if (worker_trylock()) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
worker_trylock(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user