diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-10-12 09:55:00 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-10-12 09:55:00 -0400 |
commit | 5b169c105077981eb27245d2babe2f4d6d24473f (patch) | |
tree | 5efb4e86b15f59e6b2996b71bdd0e75506bc413d /jackd | |
parent | f933fb17aa702e8a0eccf87c1e3c170109dadff3 (diff) | |
download | jack1-5b169c105077981eb27245d2babe2f4d6d24473f.tar.gz |
if started as a temporary server, count only external clients when deciding whether to keep running
Diffstat (limited to 'jackd')
-rw-r--r-- | jackd/clientengine.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/jackd/clientengine.c b/jackd/clientengine.c index 593af54..df2f5f1 100644 --- a/jackd/clientengine.c +++ b/jackd/clientengine.c @@ -227,26 +227,37 @@ jack_remove_client (jack_engine_t *engine, jack_client_internal_t *client) jack_client_delete (engine, client); - /* ignore the driver, which counts as a client. */ - - if (engine->temporary && (jack_slist_length(engine->clients) <= 1)) { - if (engine->wait_pid >= 0) { - /* block new clients from being created - after we release the lock. - */ - engine->new_clients_allowed = 0; - /* tell the waiter we're done - to initiate a normal shutdown. - */ - VERBOSE (engine, "Kill wait pid to stop"); - kill (engine->wait_pid, SIGUSR2); - /* unlock the graph so that the server thread can finish */ - jack_unlock_graph (engine); - sleep (-1); - } else { - exit (0); - } + if (engine->temporary) { + int external_clients = 0; + + /* count external clients only when deciding whether to shutdown */ + + for (node = engine->clients; node; node = jack_slist_next (node)) { + jack_client_t* client = (jack_client_t*) node->data; + if (client->control->type == ClientExternal) { + external_clients++; + } + } + + if (external_clients == 0) { + if (engine->wait_pid >= 0) { + /* block new clients from being created + after we release the lock. + */ + engine->new_clients_allowed = 0; + /* tell the waiter we're done + to initiate a normal shutdown. + */ + VERBOSE (engine, "Kill wait pid to stop"); + kill (engine->wait_pid, SIGUSR2); + /* unlock the graph so that the server thread can finish */ + jack_unlock_graph (engine); + sleep (-1); + } else { + exit (0); + } + } } } |