| @@ -109,15 +109,12 @@ int JackClient::Close() | |||||
| int result = 0; | int result = 0; | ||||
| Deactivate(); | 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(); | fChannel->Close(); | ||||
| assert(JackGlobals::fSynchroMutex); | assert(JackGlobals::fSynchroMutex); | ||||
| JackGlobals::fSynchroMutex->Lock(); | JackGlobals::fSynchroMutex->Lock(); | ||||
| @@ -831,16 +831,12 @@ int JackEngine::ClientDeactivate(int refnum) | |||||
| void JackEngine::ClientKill(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); | |||||
| } | } | ||||
| } | } | ||||
| @@ -53,6 +53,12 @@ void JackGenericClientChannel::ServerSyncCall(JackRequest* req, JackResult* res, | |||||
| return; | return; | ||||
| } | } | ||||
| if (!JackGlobals::fServerRunning) { | |||||
| jack_error("Server is not running"); | |||||
| *result = -1; | |||||
| return; | |||||
| } | |||||
| if (req->Write(fRequest) < 0) { | if (req->Write(fRequest) < 0) { | ||||
| jack_error("Could not write request type = %ld", req->fType); | jack_error("Could not write request type = %ld", req->fType); | ||||
| *result = -1; | *result = -1; | ||||
| @@ -77,6 +83,12 @@ void JackGenericClientChannel::ServerAsyncCall(JackRequest* req, JackResult* res | |||||
| return; | return; | ||||
| } | } | ||||
| if (!JackGlobals::fServerRunning) { | |||||
| jack_error("Server is not running"); | |||||
| *result = -1; | |||||
| return; | |||||
| } | |||||
| if (req->Write(fRequest) < 0) { | if (req->Write(fRequest) < 0) { | ||||
| jack_error("Could not write request type = %ld", req->fType); | jack_error("Could not write request type = %ld", req->fType); | ||||
| *result = -1; | *result = -1; | ||||
| @@ -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; | int shared_engine, shared_client, shared_graph, result; | ||||
| bool res; | bool res; | ||||
| jack_log("JackLibClient::Open name = %s", name); | jack_log("JackLibClient::Open name = %s", name); | ||||
| if (strlen(name) >= JACK_CLIENT_NAME_SIZE) { | if (strlen(name) >= JACK_CLIENT_NAME_SIZE) { | ||||
| jack_error("\"%s\" is too long to be used as a JACK client name.\n" | jack_error("\"%s\" is too long to be used as a JACK client name.\n" | ||||
| "Please use %lu characters or less", | "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::fClientTable[GetClientControl()->fRefNum] = this; | ||||
| JackGlobals::fServerRunning = true; | |||||
| SetClockSource(GetEngineControl()->fClockSource); | SetClockSource(GetEngineControl()->fClockSource); | ||||
| jack_log("JackLibClient::Open name = %s refnum = %ld", name_res, GetClientControl()->fRefNum); | jack_log("JackLibClient::Open name = %s refnum = %ld", name_res, GetClientControl()->fRefNum); | ||||
| return 0; | return 0; | ||||
| @@ -39,15 +39,21 @@ JackSocketClientChannel::~JackSocketClientChannel() | |||||
| delete fNotificationSocket; | 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; | int result = 0; | ||||
| jack_log("JackSocketClientChannel::Open name = %s", name); | jack_log("JackSocketClientChannel::Open name = %s", name); | ||||
| // Before any server/client call | |||||
| fClient = client; | |||||
| if (fRequest->Connect(jack_server_dir, server_name, 0) < 0) { | if (fRequest->Connect(jack_server_dir, server_name, 0) < 0) { | ||||
| jack_error("Cannot connect to server socket"); | jack_error("Cannot connect to server socket"); | ||||
| goto error; | goto error; | ||||
| } | } | ||||
| // OK so server is there... | |||||
| JackGlobals::fServerRunning = true; | |||||
| // Check name in server | // Check name in server | ||||
| ClientCheck(name, uuid, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result, true); | 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"); | jack_error("Cannot bind socket"); | ||||
| goto error; | goto error; | ||||
| } | } | ||||
| fClient = obj; | |||||
| return 0; | return 0; | ||||
| error: | error: | ||||
| @@ -79,8 +84,9 @@ void JackSocketClientChannel::Close() | |||||
| { | { | ||||
| fRequest->Close(); | fRequest->Close(); | ||||
| fNotificationListenSocket.Close(); | fNotificationListenSocket.Close(); | ||||
| if (fNotificationSocket) | |||||
| if (fNotificationSocket) { | |||||
| fNotificationSocket->Close(); | fNotificationSocket->Close(); | ||||
| } | |||||
| } | } | ||||
| int JackSocketClientChannel::Start() | int JackSocketClientChannel::Start() | ||||
| @@ -49,7 +49,7 @@ class JackSocketClientChannel : public JackGenericClientChannel, public JackRunn | |||||
| JackSocketClientChannel(); | JackSocketClientChannel(); | ||||
| virtual ~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(); | void Close(); | ||||
| int Start(); | int Start(); | ||||
| @@ -38,7 +38,7 @@ JackWinNamedPipeClientChannel::~JackWinNamedPipeClientChannel() | |||||
| delete fRequest; | 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; | int result = 0; | ||||
| jack_log("JackWinNamedPipeClientChannel::Open name = %s", name); | jack_log("JackWinNamedPipeClientChannel::Open name = %s", name); | ||||
| @@ -50,11 +50,17 @@ int JackWinNamedPipeClientChannel::Open(const char* server_name, const char* nam | |||||
| goto error; | goto error; | ||||
| } | } | ||||
| */ | */ | ||||
| // Before any server/client call | |||||
| fClient = client; | |||||
| if (fRequest->Connect(jack_server_dir, server_name, 0) < 0) { | if (fRequest->Connect(jack_server_dir, server_name, 0) < 0) { | ||||
| jack_error("Cannot connect to server pipe"); | jack_error("Cannot connect to server pipe"); | ||||
| goto error; | goto error; | ||||
| } | } | ||||
| // OK so server is there... | |||||
| JackGlobals::fServerRunning = true; | |||||
| // Check name in server | // Check name in server | ||||
| ClientCheck(name, uuid, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result, true); | 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; | goto error; | ||||
| } | } | ||||
| fClient = obj; | |||||
| return 0; | return 0; | ||||
| error: | error: | ||||
| @@ -49,7 +49,7 @@ class JackWinNamedPipeClientChannel : public JackGenericClientChannel, public Ja | |||||
| JackWinNamedPipeClientChannel(); | JackWinNamedPipeClientChannel(); | ||||
| virtual ~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(); | void Close(); | ||||
| int Start(); | int Start(); | ||||