Commit ce5d02b5 authored by sletz's avatar sletz
Browse files

Correct JackClient::Close() to request server close only if server is running.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2759 0c269be4-1314-0410-8aa9-9f06e86f4224
parent e822ddc3
......@@ -23,9 +23,14 @@ Florian Faber
---------------------------
2008-08-01 Stephane Letz <letz@grame.fr>
* 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 <letz@grame.fr>
* Remove restriction that port connection could be done only if the client was activated.
2008-07-25 Stephane Letz <letz@grame.fr>
......
......@@ -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 <math.h>
#include <string>
#include <algorithm>
#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);
......
......@@ -89,6 +89,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
detail::JackClientChannelInterface* fChannel;
JackSynchro* fSynchroTable;
std::list<jack_port_id_t> 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.
......
......@@ -147,6 +147,7 @@ int JackInternalClient::Open(const char* server_name, const char* name, jack_opt
}
SetupDriverSync(false);
fServerRunning = true;
return 0;
error:
......
......@@ -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;
}
}
......
......@@ -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:
......
......@@ -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;
}
}
......
......@@ -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;
......
......@@ -83,11 +83,11 @@ void JackSocketServerChannel::Close()
// Close remaining client sockets
std::map<int, std::pair<int, JackClientSocket*> >::iterator it;
for (it = fSocketTable.begin(); it != fSocketTable.end(); it++) {
pair<int, JackClientSocket*> elem = (*it).second;
JackClientSocket* socket = elem.second;
assert(socket);
socket->Close();
delete socket;
pair<int, JackClientSocket*> elem = (*it).second;
JackClientSocket* socket = elem.second;
assert(socket);
socket->Close();
delete socket;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment