Browse Source

Better handling of shutdown state in client side.

tags/v1.9.10
Stephane Letz 12 years ago
parent
commit
7ec46dbb46
8 changed files with 44 additions and 29 deletions
  1. +6
    -9
      common/JackClient.cpp
  2. +6
    -10
      common/JackEngine.cpp
  3. +12
    -0
      common/JackGenericClientChannel.cpp
  4. +1
    -2
      common/JackLibClient.cpp
  5. +10
    -4
      posix/JackSocketClientChannel.cpp
  6. +1
    -1
      posix/JackSocketClientChannel.h
  7. +7
    -2
      windows/JackWinNamedPipeClientChannel.cpp
  8. +1
    -1
      windows/JackWinNamedPipeClientChannel.h

+ 6
- 9
common/JackClient.cpp View File

@@ -109,15 +109,12 @@ int JackClient::Close()
int result = 0;

Deactivate();
fChannel->Stop(); // Channels is stopped first to avoid receiving notifications while closing

// Request close only if server is still running
if (JackGlobals::fServerRunning) {
fChannel->ClientClose(GetClientControl()->fRefNum, &result);
} else {
jack_log("JackClient::Close server is shutdown");
}

// Channels is stopped first to avoid receiving notifications while closing
fChannel->Stop();
// Then close client
fChannel->ClientClose(GetClientControl()->fRefNum, &result);
fChannel->Close();
assert(JackGlobals::fSynchroMutex);
JackGlobals::fSynchroMutex->Lock();


+ 6
- 10
common/JackEngine.cpp View File

@@ -831,16 +831,12 @@ int JackEngine::ClientDeactivate(int refnum)

void JackEngine::ClientKill(int refnum)
{
if (fClientTable[refnum]) {
jack_log("JackEngine::ClientKill ref = %ld", refnum);
if (ClientDeactivate(refnum) < 0) {
jack_error("JackEngine::ClientKill ref = %ld cannot be removed from the graph !!", refnum);
}
if (ClientExternalClose(refnum) < 0) {
jack_error("JackEngine::ClientKill ref = %ld cannot be closed", refnum);
}
} else {
jack_log("JackEngine::ClientKill ref = %ld probably already killed...", refnum);
jack_log("JackEngine::ClientKill ref = %ld", refnum);
if (ClientDeactivate(refnum) < 0) {
jack_error("JackEngine::ClientKill ref = %ld cannot be removed from the graph !!", refnum);
}
if (ClientExternalClose(refnum) < 0) {
jack_error("JackEngine::ClientKill ref = %ld cannot be closed", refnum);
}
}



+ 12
- 0
common/JackGenericClientChannel.cpp View File

@@ -53,6 +53,12 @@ void JackGenericClientChannel::ServerSyncCall(JackRequest* req, JackResult* res,
return;
}
if (!JackGlobals::fServerRunning) {
jack_error("Server is not running");
*result = -1;
return;
}
if (req->Write(fRequest) < 0) {
jack_error("Could not write request type = %ld", req->fType);
*result = -1;
@@ -77,6 +83,12 @@ void JackGenericClientChannel::ServerAsyncCall(JackRequest* req, JackResult* res
return;
}
if (!JackGlobals::fServerRunning) {
jack_error("Server is not running");
*result = -1;
return;
}
if (req->Write(fRequest) < 0) {
jack_error("Could not write request type = %ld", req->fType);
*result = -1;


+ 1
- 2
common/JackLibClient.cpp View File

@@ -86,7 +86,7 @@ int JackLibClient::Open(const char* server_name, const char* name, int uuid, jac
int shared_engine, shared_client, shared_graph, result;
bool res;
jack_log("JackLibClient::Open name = %s", name);
if (strlen(name) >= JACK_CLIENT_NAME_SIZE) {
jack_error("\"%s\" is too long to be used as a JACK client name.\n"
"Please use %lu characters or less",
@@ -141,7 +141,6 @@ int JackLibClient::Open(const char* server_name, const char* name, int uuid, jac
}

JackGlobals::fClientTable[GetClientControl()->fRefNum] = this;
JackGlobals::fServerRunning = true;
SetClockSource(GetEngineControl()->fClockSource);
jack_log("JackLibClient::Open name = %s refnum = %ld", name_res, GetClientControl()->fRefNum);
return 0;


+ 10
- 4
posix/JackSocketClientChannel.cpp View File

@@ -39,15 +39,21 @@ JackSocketClientChannel::~JackSocketClientChannel()
delete fNotificationSocket;
}

int JackSocketClientChannel::Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status)
int JackSocketClientChannel::Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status)
{
int result = 0;
jack_log("JackSocketClientChannel::Open name = %s", name);
// Before any server/client call
fClient = client;

if (fRequest->Connect(jack_server_dir, server_name, 0) < 0) {
jack_error("Cannot connect to server socket");
goto error;
}
// OK so server is there...
JackGlobals::fServerRunning = true;

// Check name in server
ClientCheck(name, uuid, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result, true);
@@ -65,8 +71,7 @@ int JackSocketClientChannel::Open(const char* server_name, const char* name, int
jack_error("Cannot bind socket");
goto error;
}

fClient = obj;
return 0;

error:
@@ -79,8 +84,9 @@ void JackSocketClientChannel::Close()
{
fRequest->Close();
fNotificationListenSocket.Close();
if (fNotificationSocket)
if (fNotificationSocket) {
fNotificationSocket->Close();
}
}

int JackSocketClientChannel::Start()


+ 1
- 1
posix/JackSocketClientChannel.h View File

@@ -49,7 +49,7 @@ class JackSocketClientChannel : public JackGenericClientChannel, public JackRunn
JackSocketClientChannel();
virtual ~JackSocketClientChannel();

int Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status);
int Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status);
void Close();

int Start();


+ 7
- 2
windows/JackWinNamedPipeClientChannel.cpp View File

@@ -38,7 +38,7 @@ JackWinNamedPipeClientChannel::~JackWinNamedPipeClientChannel()
delete fRequest;
}

int JackWinNamedPipeClientChannel::Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status)
int JackWinNamedPipeClientChannel::Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status)
{
int result = 0;
jack_log("JackWinNamedPipeClientChannel::Open name = %s", name);
@@ -50,11 +50,17 @@ int JackWinNamedPipeClientChannel::Open(const char* server_name, const char* nam
goto error;
}
*/
// Before any server/client call
fClient = client;

if (fRequest->Connect(jack_server_dir, server_name, 0) < 0) {
jack_error("Cannot connect to server pipe");
goto error;
}
// OK so server is there...
JackGlobals::fServerRunning = true;

// Check name in server
ClientCheck(name, uuid, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result, true);
@@ -72,7 +78,6 @@ int JackWinNamedPipeClientChannel::Open(const char* server_name, const char* nam
goto error;
}

fClient = obj;
return 0;

error:


+ 1
- 1
windows/JackWinNamedPipeClientChannel.h View File

@@ -49,7 +49,7 @@ class JackWinNamedPipeClientChannel : public JackGenericClientChannel, public Ja
JackWinNamedPipeClientChannel();
virtual ~JackWinNamedPipeClientChannel();

int Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status);
int Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status);
void Close();

int Start();


Loading…
Cancel
Save