Browse Source

fixed race condition with client removal

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@98 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.109.0
pbd 24 years ago
parent
commit
bb77c5c4db
4 changed files with 23 additions and 27 deletions
  1. +7
    -6
      client.c
  2. +1
    -1
      configure.in
  3. +14
    -19
      engine.c
  4. +1
    -1
      jackd.c

+ 7
- 6
client.c View File

@@ -731,7 +731,7 @@ jack_client_close (jack_client_t *client)
req.type = DropClient;
req.x.client_id = client->control->id;

/* stop the thread */
/* stop the thread that communicates with the jack server */

pthread_cancel (client->thread);
pthread_join (client->thread, &status);
@@ -740,13 +740,14 @@ jack_client_close (jack_client_t *client)
shmdt (client->engine);

for (node = client->port_segments; node; node = g_slist_next (node)) {
jack_port_segment_info_t *si;
si = (jack_port_segment_info_t *) node->data;
shmdt (si->address);
free (si);
shmdt (((jack_port_segment_info_t *) node->data)->address);
free (node->data);
}

g_slist_free (client->port_segments);

for (node = client->ports; node; node = g_slist_next (node)) {
free (node->data);
}
g_slist_free (client->ports);

if (client->graph_wait_fd) {


+ 1
- 1
configure.in View File

@@ -5,7 +5,7 @@ AC_CONFIG_AUX_DIR(.)

JACK_MAJOR_VERSION=0
JACK_MINOR_VERSION=10
JACK_MICRO_VERSION=0
JACK_MICRO_VERSION=1

BETA=



+ 14
- 19
engine.c View File

@@ -192,15 +192,16 @@ jack_cleanup_clients (jack_engine_t *engine)
{
jack_client_control_t *ctl;
jack_client_internal_t *client;
GSList *node;
GSList *remove = 0;
GSList *node, *tmp;
static int x = 0;

x++;

pthread_mutex_lock (&engine->graph_lock);

for (node = engine->clients; node; node = g_slist_next (node)) {
for (node = engine->clients; node; ) {

tmp = g_slist_next (node);
client = (jack_client_internal_t *) node->data;
ctl = client->control;
@@ -210,20 +211,18 @@ jack_cleanup_clients (jack_engine_t *engine)
}

if (ctl->state > NotTriggered) {
remove = g_slist_prepend (remove, node->data);
if (engine->verbose) {
fprintf (stderr, "%d: removing failed client %s\n", x, ctl->name);
}
}
}
pthread_mutex_unlock (&engine->graph_lock);
if (remove) {
for (node = remove; node; node = g_slist_next (node)) {

jack_remove_client (engine, (jack_client_internal_t *) node->data);
}
g_slist_free (remove);

node = tmp;
}

pthread_mutex_unlock (&engine->graph_lock);
}

static int
@@ -840,14 +839,14 @@ handle_client_jack_error (jack_engine_t *engine, int fd)
}
}

pthread_mutex_unlock (&engine->graph_lock);

if (client == 0) {
pthread_mutex_unlock (&engine->graph_lock);
jack_error ("i/o error on unknown client fd %d", fd);
return -1;
}

jack_remove_client (engine, client);
pthread_mutex_unlock (&engine->graph_lock);
return 0;
}

@@ -1384,8 +1383,6 @@ jack_remove_client (jack_engine_t *engine, jack_client_internal_t *client)
fprintf (stderr, "removing client %s\n", client->control->name);
}

pthread_mutex_lock (&engine->graph_lock);
client->control->dead = TRUE;

if (client == engine->timebase_client) {
@@ -1422,8 +1419,6 @@ jack_remove_client (jack_engine_t *engine, jack_client_internal_t *client)
close (client->request_fd);

jack_client_delete (engine, client);

pthread_mutex_unlock (&engine->graph_lock);
}

static void
@@ -1875,9 +1870,9 @@ jack_port_do_connect (jack_engine_t *engine,

dstport->connections = g_slist_prepend (dstport->connections, connection);
srcport->connections = g_slist_prepend (srcport->connections, connection);

jack_sort_graph (engine, FALSE);
jack_sort_graph (engine, FALSE);

jack_send_connection_notification (engine, srcport->shared->client_id, src_id, dst_id, TRUE);
jack_send_connection_notification (engine, dstport->shared->client_id, dst_id, src_id, TRUE);
}


+ 1
- 1
jackd.c View File

@@ -284,9 +284,9 @@ main (int argc, char *argv[])
hw_monitoring = 1;
break;

case 'h':
default:
fprintf (stderr, "unknown option character %c\n", opt);
case 'h':
usage();
return -1;
}


Loading…
Cancel
Save