Commit ed864f55 authored by sletz's avatar sletz
Browse files

Now start server channel thread only when backend has been started (so in...

Now start server channel thread only when backend has been started (so in JackServer::Start). Should solve race conditions at start time.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3662 0c269be4-1314-0410-8aa9-9f06e86f4224
parent c716c75d
......@@ -29,6 +29,7 @@ Paul Davis
* Correct JackProcessSync::LockedTimedWait.
* Correct JACK_MESSAGE_SIZE value, particularly in OSX RPC code.
* Now start server channel thread only when backend has been started (so in JackServer::Start). Should solve race conditions at start time.
2009-10-22 Stephane Letz <letz@grame.fr>
......
......@@ -78,7 +78,7 @@ int JackServer::Open(jack_driver_desc_t* driver_desc, JSList* driver_params)
goto fail_close1;
}
if (fEngine->Open() != 0) {
if (fEngine->Open() < 0) {
jack_error("Cannot open engine");
goto fail_close2;
}
......@@ -88,12 +88,12 @@ int JackServer::Open(jack_driver_desc_t* driver_desc, JSList* driver_params)
goto fail_close3;
}
if (fFreewheelDriver->Open() != 0) { // before engine open
if (fFreewheelDriver->Open() < 0) { // before engine open
jack_error("Cannot open driver");
goto fail_close4;
}
if (fAudioDriver->Attach() != 0) {
if (fAudioDriver->Attach() < 0) {
jack_error("Cannot attach audio driver");
goto fail_close5;
}
......@@ -168,7 +168,10 @@ int JackServer::InternalClientLoadAux(JackLoadableInternalClient* client, const
int JackServer::Start()
{
jack_log("JackServer::Start");
return fAudioDriver->Start();
if (fAudioDriver->Start() < 0) {
return -1;
}
return fChannel.Start();
}
int JackServer::Stop()
......
......@@ -50,11 +50,6 @@ int JackMachServerChannel::Open(const char* server_name, JackServer* server)
return -1;
}
if (fThread.Start() != 0) {
jack_error("Cannot start Jack server listener");
return -1;
}
fServer = server;
fPortTable[fServerPort.GetPort()] = this;
return 0;
......@@ -66,6 +61,16 @@ void JackMachServerChannel::Close()
fThread.Kill();
fServerPort.DestroyPort();
}
int JackMachServerChannel::Start()
{
if (fThread.Start() != 0) {
jack_error("Cannot start Jack server listener");
return -1;
}
return 0;
}
JackLockedEngine* JackMachServerChannel::GetEngine()
{
......
......@@ -53,6 +53,8 @@ class JackMachServerChannel : public JackRunnableInterface
int Open(const char* server_name, JackServer* server); // Open the Server/Client connection
void Close(); // Close the Server/Client connection
int Start();
JackLockedEngine* GetEngine();
JackServer* GetServer();
......@@ -64,6 +66,7 @@ class JackMachServerChannel : public JackRunnableInterface
bool Execute();
// Has to be public..
static std::map<mach_port_t, JackMachServerChannel*> fPortTable;
};
......
......@@ -48,9 +48,8 @@ JackSocketServerChannel::~JackSocketServerChannel()
int JackSocketServerChannel::Open(const char* server_name, JackServer* server)
{
jack_log("JackSocketServerChannel::Open ");
fServer = server;
jack_log("JackSocketServerChannel::Open");
// Prepare request socket
if (fRequestListenSocket.Bind(jack_server_dir, server_name, 0) < 0) {
jack_log("JackSocketServerChannel::Open : cannot create result listen socket");
......@@ -59,13 +58,7 @@ int JackSocketServerChannel::Open(const char* server_name, JackServer* server)
// Prepare for poll
BuildPoolTable();
// Start listening
if (fThread.Start() != 0) {
jack_error("Cannot start Jack server listener");
goto error;
}
fServer = server;
return 0;
error:
......@@ -88,6 +81,16 @@ void JackSocketServerChannel::Close()
delete socket;
}
}
int JackSocketServerChannel::Start()
{
if (fThread.Start() != 0) {
jack_error("Cannot start Jack server listener");
return -1;
}
return 0;
}
void JackSocketServerChannel::ClientCreate()
{
......
......@@ -59,8 +59,10 @@ class JackSocketServerChannel : public JackRunnableInterface
JackSocketServerChannel();
~JackSocketServerChannel();
int Open(const char* server_name, JackServer* server); // Open the Server/Client connection
void Close(); // Close the Server/Client connection
int Open(const char* server_name, JackServer* server); // Open the Server/Client connection
void Close(); // Close the Server/Client connection
int Start();
// JackRunnableInterface interface
bool Init();
......
......@@ -31,15 +31,17 @@ using namespace std;
namespace Jack
{
HANDLE JackClientPipeThread::fMutex = NULL; // never released....
HANDLE JackClientPipeThread::fMutex = NULL; // Never released....
// fRefNum = -1 correspond to already removed client
JackClientPipeThread::JackClientPipeThread(JackWinNamedPipeClient* pipe)
: fPipe(pipe), fServer(NULL), fThread(this), fRefNum(0)
:fPipe(pipe), fServer(NULL), fThread(this), fRefNum(0)
{
if (fMutex == NULL)
// First one allocated the static fMutex
if (fMutex == NULL) {
fMutex = CreateMutex(NULL, FALSE, NULL);
}
}
JackClientPipeThread::~JackClientPipeThread()
......@@ -51,14 +53,7 @@ JackClientPipeThread::~JackClientPipeThread()
int JackClientPipeThread::Open(JackServer* server) // Open the Server/Client connection
{
fServer = server;
// Start listening
if (fThread.Start() != 0) {
jack_error("Cannot start Jack server listener\n");
return -1;
} else {
return 0;
}
return 0;
}
void JackClientPipeThread::Close() // Close the Server/Client connection
......@@ -74,6 +69,16 @@ void JackClientPipeThread::Close() // Close the Server/Client connection
fPipe->Close();
fRefNum = -1;
}
int JackClientPipeThread::Start()
{
if (fThread.Start() != 0) {
jack_error("Cannot start Jack server listener");
return -1;
}
return 0;
}
bool JackClientPipeThread::Execute()
{
......
......@@ -50,8 +50,10 @@ class JackClientPipeThread : public JackRunnableInterface
JackClientPipeThread(JackWinNamedPipeClient* pipe);
virtual ~JackClientPipeThread();
int Open(JackServer* server); // Open the Server/Client connection
void Close(); // Close the Server/Client connection
int Open(JackServer* server); // Open the Server/Client connection
void Close(); // Close the Server/Client connection
int Start();
bool HandleRequest();
......
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