Browse Source

[0.99.37] better jack_client_open() error checking

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@847 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.109.0
joq 21 years ago
parent
commit
56dfc08414
6 changed files with 39 additions and 21 deletions
  1. +2
    -2
      configure.ac
  2. +1
    -1
      jack/internal.h
  3. +11
    -1
      jack/types.h
  4. +17
    -3
      jackd/clientengine.c
  5. +0
    -6
      jackd/engine.c
  6. +8
    -8
      libjack/client.c

+ 2
- 2
configure.ac View File

@@ -15,7 +15,7 @@ dnl changes are made
dnl ---
JACK_MAJOR_VERSION=0
JACK_MINOR_VERSION=99
JACK_MICRO_VERSION=36
JACK_MICRO_VERSION=37

dnl ---
dnl HOWTO: updating the jack protocol version
@@ -25,7 +25,7 @@ dnl made to the way libjack communicates with jackd
dnl that would break applications linked with an older
dnl version of libjack.
dnl ---
JACK_PROTOCOL_VERSION=14
JACK_PROTOCOL_VERSION=15

dnl ---
dnl HOWTO: updating the libjack interface version


+ 1
- 1
jack/internal.h View File

@@ -250,6 +250,7 @@ typedef volatile struct {

typedef struct {
uint32_t protocol_v; /* protocol version, must go first */
int32_t load;
ClientType type;
jack_options_t options;
@@ -262,7 +263,6 @@ typedef struct {

typedef struct {

uint32_t protocol_v;
jack_status_t status;

jack_shm_info_t client_shm;


+ 11
- 1
jack/types.h View File

@@ -351,7 +351,17 @@ enum JackStatus {
/**
* Unable to initialize client
*/
JackInitFailure = 0x100
JackInitFailure = 0x100,

/**
* Unable to access shared memory
*/
JackShmFailure = 0x200,

/**
* Client's protocol version does not match
*/
JackVersionError = 0x400
};

/**


+ 17
- 3
jackd/clientengine.c View File

@@ -650,10 +650,25 @@ jack_client_create (jack_engine_t *engine, int client_fd)
jack_client_internal_t *client;
jack_client_connect_request_t req;
jack_client_connect_result_t res;
ssize_t nbytes;

res.status = 0;

if (read (client_fd, &req, sizeof (req)) != sizeof (req)) {
nbytes = read (client_fd, &req, sizeof (req));

if ((nbytes < sizeof (req.protocol_v))
|| (req.protocol_v != jack_protocol_version)) {

/* JACK protocol incompatibility */
res.status |= (JackFailure|JackVersionError);
jack_error ("JACK protocol mismatch");
if (write (client_fd, &res, sizeof (res)) != sizeof (res)) {
jack_error ("cannot write client connection response");
}
return -1;
}

if (nbytes != sizeof (req)) {
jack_error ("cannot read connection request from client");
return -1;
}
@@ -680,7 +695,6 @@ jack_client_create (jack_engine_t *engine, int client_fd)
res.status |= JackFailure; /* just making sure */
return -1;
}
res.protocol_v = jack_protocol_version;
res.client_shm = client->control_shm;
res.engine_shm = engine->control_shm;
res.realtime = engine->control->real_time;
@@ -699,7 +713,7 @@ jack_client_create (jack_engine_t *engine, int client_fd)
strcpy (res.fifo_prefix, engine->fifo_prefix);
}

if (write (client->request_fd, &res, sizeof (res)) != sizeof (res)) {
if (write (client_fd, &res, sizeof (res)) != sizeof (res)) {
jack_error ("cannot write connection response to client");
jack_client_delete (engine, client);
return -1;


+ 0
- 6
jackd/engine.c View File

@@ -1489,12 +1489,6 @@ jack_server_thread (void *arg)
return 0;
}


static void
jack_engine_reset_frame_timer (jack_engine_t* engine)
{
}

jack_engine_t *
jack_engine_new (int realtime, int rtpriority, int do_mlock, int do_unlock,
const char *server_name, int temporary, int verbose,


+ 8
- 8
libjack/client.c View File

@@ -600,6 +600,8 @@ jack_request_client (ClientType type,
*status |= JackServerStarted;
}

/* format connection request */
req.protocol_v = jack_protocol_version;
req.load = TRUE;
req.type = type;
snprintf (req.name, sizeof (req.name),
@@ -641,18 +643,15 @@ jack_request_client (ClientType type,
*status |= res->status; /* return server status bits */

if (*status & JackFailure) {
jack_error ("could not attach as client");
if (*status & JackVersionError) {
jack_error ("client linked with incompatible libjack"
" version.");
}
jack_error ("could not attach to JACK server");
*status |= JackServerError;
goto fail;
}

if (res->protocol_v != jack_protocol_version){
jack_error ("application linked against incompatible libjack"
" version.");
*status |= (JackFailure|JackServerError);
goto fail;
}

switch (type) {
case ClientDriver:
case ClientInternal:
@@ -788,6 +787,7 @@ jack_client_open (const char *client_name,
/* don't access shared memory until server connected */
if (jack_initialize_shm ()) {
jack_error ("Unable to initialize shared memory.");
*status |= (JackFailure|JackShmFailure);
return NULL;
}



Loading…
Cancel
Save