From b7eed771d1bc9b29cbe2c3f796e496ffb83bda62 Mon Sep 17 00:00:00 2001 From: torben Date: Sun, 29 May 2011 00:47:11 +0000 Subject: [PATCH] [engine] relax the rules for zombification we now give a client which didnt finish, a bit more time to complete its process_cb. this should prevent most cases of unjustified client zombification. however we can get streams of xruns, because we can overload the cpu now. git-svn-id: svn+ssh://jackaudio.org/trunk/jack@4428 0c269be4-1314-0410-8aa9-9f06e86f4224 --- jackd/clientengine.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/jackd/clientengine.c b/jackd/clientengine.c index d7402c4..873df48 100644 --- a/jackd/clientengine.c +++ b/jackd/clientengine.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -269,9 +270,23 @@ jack_check_clients (jack_engine_t* engine, int with_timeout_check) if (client->control->awake_at > 0) { if (client->control->finished_at == 0) { - client->control->timed_out++; - client->error++; - VERBOSE (engine, "client %s has timed out", client->control->name); + jack_time_t now = jack_get_microseconds(); + + if ((now - client->control->awake_at) < engine->driver->period_usecs) { + /* we give the client a bit of time, to finish the cycle + * we assume here, that we dont get signals delivered to this thread. + */ + struct timespec wait_time; + wait_time.tv_sec = 0; + wait_time.tv_nsec = engine->driver->period_usecs - (now - client->control->awake_at); + nanosleep (&wait_time, NULL); + } + + if (client->control->finished_at == 0) { + client->control->timed_out++; + client->error++; + VERBOSE (engine, "client %s has timed out", client->control->name); + } } } }