diff --git a/ChangeLog b/ChangeLog index 80d543be..a4b2949f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,9 +23,14 @@ Florian Faber --------------------------- 2008-08-01 Stephane Letz - + * Fix desallocation of remaining clients when server quits. - * Close remaining client sockets in JackSocketServerChannel::Close. + * Close remaining client sockets in JackSocketServerChannel::Close. + * Correct JackClient::Close() to request server close only if server is running. + +2008-07-30 Stephane Letz + + * Remove restriction that port connection could be done only if the client was activated. 2008-07-25 Stephane Letz diff --git a/common/JackClient.cpp b/common/JackClient.cpp index 99441167..6dfd74b9 100644 --- a/common/JackClient.cpp +++ b/common/JackClient.cpp @@ -30,10 +30,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "JackChannel.h" #include "JackTransportEngine.h" #include "driver_interface.h" +#include "JackLibGlobals.h" + #include #include #include -#include "JackPlatformThread.h" using namespace std; @@ -41,7 +42,7 @@ namespace Jack { #define IsRealTime() ((fProcess != NULL) | (fThreadFun != NULL) | (fSync != NULL) | (fTimebase != NULL)) - + JackClient::JackClient():fThread(this) {} @@ -74,19 +75,25 @@ JackClient::JackClient(JackSynchro* table):fThread(this) fSyncArg = NULL; fTimebaseArg = NULL; fThreadFunArg = NULL; + fServerRunning = false; } JackClient::~JackClient() -{ -} +{} int JackClient::Close() { jack_log("JackClient::Close ref = %ld", GetClientControl()->fRefNum); + int result = 0; Deactivate(); - int result = -1; fChannel->Stop(); // Channels is stopped first to avoid receiving notifications while closing - fChannel->ClientClose(GetClientControl()->fRefNum, &result); + + // Request close only is server is still running + if (fServerRunning) { + fChannel->ClientClose(GetClientControl()->fRefNum, &result); + } else { + jack_log("JackClient::Close server is shutdown"); + } fChannel->Close(); fSynchroTable[GetClientControl()->fRefNum].Disconnect(); return result; @@ -574,6 +581,7 @@ ShutDown is called: void JackClient::ShutDown() { jack_log("ShutDown"); + fServerRunning = false; if (fShutdown) { GetClientControl()->fActive = false; fShutdown(fShutdownArg); diff --git a/common/JackClient.h b/common/JackClient.h index f78ebf7b..939ff4da 100644 --- a/common/JackClient.h +++ b/common/JackClient.h @@ -89,6 +89,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface detail::JackClientChannelInterface* fChannel; JackSynchro* fSynchroTable; std::list fPortList; + bool fServerRunning; int StartThread(); void SetupDriverSync(bool freewheel); @@ -183,6 +184,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface // JackRunnableInterface interface bool Init(); bool Execute(); + }; // Each "side" server and client will implement this to get the shared graph manager, engine control and inter-process synchro table. diff --git a/common/JackInternalClient.cpp b/common/JackInternalClient.cpp index e51e996d..144b419b 100644 --- a/common/JackInternalClient.cpp +++ b/common/JackInternalClient.cpp @@ -147,6 +147,7 @@ int JackInternalClient::Open(const char* server_name, const char* name, jack_opt } SetupDriverSync(false); + fServerRunning = true; return 0; error: diff --git a/common/JackLibAPI.cpp b/common/JackLibAPI.cpp index 5cccdf4f..ac415a7f 100644 --- a/common/JackLibAPI.cpp +++ b/common/JackLibAPI.cpp @@ -137,8 +137,8 @@ EXPORT int jack_client_close(jack_client_t* ext_client) } else { int res = client->Close(); delete client; - jack_log("jack_client_close OK"); JackLibGlobals::Destroy(); // jack library destruction + jack_log("jack_client_close res = %d", res); return res; } } diff --git a/common/JackLibClient.cpp b/common/JackLibClient.cpp index 05e8441e..e09457ab 100644 --- a/common/JackLibClient.cpp +++ b/common/JackLibClient.cpp @@ -116,8 +116,9 @@ int JackLibClient::Open(const char* server_name, const char* name, jack_options_ jack_error("Cannot ConnectSemaphore %s client", name_res); goto error; } - + jack_log("JackLibClient::Open name = %s refnum = %ld", name_res, GetClientControl()->fRefNum); + fServerRunning = true; return 0; error: diff --git a/common/JackServerAPI.cpp b/common/JackServerAPI.cpp index ae8dc3ed..f047c4e8 100644 --- a/common/JackServerAPI.cpp +++ b/common/JackServerAPI.cpp @@ -143,10 +143,10 @@ EXPORT int jack_client_close(jack_client_t* ext_client) } else { int res = client->Close(); delete client; - jack_log("jack_client_close OK"); if (!g_nostart) { JackServerGlobals::Destroy(); // jack server destruction } + jack_log("jack_client_close res = %d", res); return res; } } diff --git a/common/JackSocketClientChannel.cpp b/common/JackSocketClientChannel.cpp index 51d09af6..b5c63e21 100644 --- a/common/JackSocketClientChannel.cpp +++ b/common/JackSocketClientChannel.cpp @@ -124,13 +124,13 @@ void JackSocketClientChannel::ServerSyncCall(JackRequest* req, JackResult* res, if (req->Write(&fRequestSocket) < 0) { jack_error("Could not write request type = %ld", req->fType); *result = -1; - return ; + return; } if (res->Read(&fRequestSocket) < 0) { jack_error("Could not read result type = %ld", req->fType); *result = -1; - return ; + return; } *result = res->fResult; diff --git a/common/JackSocketServerChannel.cpp b/common/JackSocketServerChannel.cpp index c96fe912..8e7dfd4b 100644 --- a/common/JackSocketServerChannel.cpp +++ b/common/JackSocketServerChannel.cpp @@ -83,11 +83,11 @@ void JackSocketServerChannel::Close() // Close remaining client sockets std::map >::iterator it; for (it = fSocketTable.begin(); it != fSocketTable.end(); it++) { - pair elem = (*it).second; - JackClientSocket* socket = elem.second; - assert(socket); - socket->Close(); - delete socket; + pair elem = (*it).second; + JackClientSocket* socket = elem.second; + assert(socket); + socket->Close(); + delete socket; } }