Browse Source

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
tags/1.90
sletz 17 years ago
parent
commit
ce5d02b5d9
9 changed files with 35 additions and 18 deletions
  1. +7
    -2
      ChangeLog
  2. +14
    -6
      common/JackClient.cpp
  3. +2
    -0
      common/JackClient.h
  4. +1
    -0
      common/JackInternalClient.cpp
  5. +1
    -1
      common/JackLibAPI.cpp
  6. +2
    -1
      common/JackLibClient.cpp
  7. +1
    -1
      common/JackServerAPI.cpp
  8. +2
    -2
      common/JackSocketClientChannel.cpp
  9. +5
    -5
      common/JackSocketServerChannel.cpp

+ 7
- 2
ChangeLog View File

@@ -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>



+ 14
- 6
common/JackClient.cpp View File

@@ -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);


+ 2
- 0
common/JackClient.h View File

@@ -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.


+ 1
- 0
common/JackInternalClient.cpp View File

@@ -147,6 +147,7 @@ int JackInternalClient::Open(const char* server_name, const char* name, jack_opt
}

SetupDriverSync(false);
fServerRunning = true;
return 0;

error:


+ 1
- 1
common/JackLibAPI.cpp View File

@@ -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;
}
}


+ 2
- 1
common/JackLibClient.cpp View File

@@ -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:


+ 1
- 1
common/JackServerAPI.cpp View File

@@ -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;
}
}


+ 2
- 2
common/JackSocketClientChannel.cpp View File

@@ -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;


+ 5
- 5
common/JackSocketServerChannel.cpp View File

@@ -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;
}
}



Loading…
Cancel
Save