From 1864b36159285ebc9bd650e161ff34dc1e8d9051 Mon Sep 17 00:00:00 2001 From: sletz Date: Sat, 17 Oct 2009 19:59:11 +0000 Subject: [PATCH] Correct server temporary mode : now set a global and quit after server/client message handling is finished. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3650 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 6 +++++- common/JackEngine.cpp | 4 +--- common/JackGlobals.h | 2 +- common/JackServerGlobals.cpp | 1 + common/JackServerGlobals.h | 1 + macosx/JackMachServerChannel.cpp | 5 +++++ posix/JackSocketServerChannel.cpp | 7 +++++++ windows/JackWinNamedPipeServerChannel.cpp | 7 +++++++ 8 files changed, 28 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1c3de1cf..1827b00e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,7 +23,11 @@ Paul Davis --------------------------- Jackdmp changes log ---------------------------- +--------------------------- + +2009-10-17 Stephane Letz + + * Correct server temporary mode : now set a global and quit after server/client message handling is finished. 2009-10-15 Stephane Letz diff --git a/common/JackEngine.cpp b/common/JackEngine.cpp index 20b8f16b..bddfeaa0 100644 --- a/common/JackEngine.cpp +++ b/common/JackEngine.cpp @@ -119,9 +119,7 @@ void JackEngine::ReleaseRefnum(int ref) // last client and temporay case: quit the server jack_log("JackEngine::ReleaseRefnum server quit"); fEngineControl->fTemporary = false; -#ifndef WIN32 - exit(0); -#endif + JackServerGlobals::fKilled = true; } } } diff --git a/common/JackGlobals.h b/common/JackGlobals.h index f5516f73..8dfe7f92 100644 --- a/common/JackGlobals.h +++ b/common/JackGlobals.h @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace Jack { -// Globals used for client management on server or libray side. +// Globals used for client management on server or library side. struct JackGlobals { static jack_tls_key fRealTime; diff --git a/common/JackServerGlobals.cpp b/common/JackServerGlobals.cpp index 7698c640..18dfaf66 100644 --- a/common/JackServerGlobals.cpp +++ b/common/JackServerGlobals.cpp @@ -28,6 +28,7 @@ static char* server_name = NULL; namespace Jack { +bool JackServerGlobals::fKilled = false; JackServer* JackServerGlobals::fInstance; unsigned int JackServerGlobals::fUserCount; bool (* JackServerGlobals::on_device_acquire)(const char * device_name) = NULL; diff --git a/common/JackServerGlobals.h b/common/JackServerGlobals.h index fac85bd3..0b842dfc 100644 --- a/common/JackServerGlobals.h +++ b/common/JackServerGlobals.h @@ -36,6 +36,7 @@ class JackClient; struct SERVER_EXPORT JackServerGlobals { + static bool fKilled; static JackServer* fInstance; static unsigned int fUserCount; static bool (* on_device_acquire)(const char * device_name); diff --git a/macosx/JackMachServerChannel.cpp b/macosx/JackMachServerChannel.cpp index 84d87b93..5c2ad667 100644 --- a/macosx/JackMachServerChannel.cpp +++ b/macosx/JackMachServerChannel.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "JackServer.h" #include "JackLockedEngine.h" #include "JackNotification.h" +#include "JackServerGlobals.h" using namespace std; @@ -137,6 +138,10 @@ boolean_t JackMachServerChannel::MessageHandler(mach_msg_header_t* Request, mach channel->ClientKill(Request->msgh_local_port); } else { JackRPCEngine_server(Request, Reply); + // Issued by JackEngine::ReleaseRefnum when temporary mode is used + if (JackServerGlobals::fKilled) { + kill(JackTools::GetPID(), SIGINT); + } } return true; } diff --git a/posix/JackSocketServerChannel.cpp b/posix/JackSocketServerChannel.cpp index b04fdb0a..bac47da9 100644 --- a/posix/JackSocketServerChannel.cpp +++ b/posix/JackSocketServerChannel.cpp @@ -395,6 +395,13 @@ bool JackSocketServerChannel::HandleRequest(int fd) jack_error("Unknown request %ld", header.fType); break; } + + /* TODO + // Issued by JackEngine::ReleaseRefnum when temporary mode is used + if (JackServerGlobals::fKilled) { + kill(JackTools::GetPID(), SIGINT); + } + */ return true; } diff --git a/windows/JackWinNamedPipeServerChannel.cpp b/windows/JackWinNamedPipeServerChannel.cpp index f3f2c288..41576b10 100644 --- a/windows/JackWinNamedPipeServerChannel.cpp +++ b/windows/JackWinNamedPipeServerChannel.cpp @@ -316,6 +316,13 @@ bool JackClientPipeThread::HandleRequest() break; } } + + /* TODO + // Issued by JackEngine::ReleaseRefnum when temporary mode is used + if (JackServerGlobals::fKilled) { + kill(JackTools::GetPID(), SIGINT); + } + */ // Unlock the global mutex ReleaseMutex(fMutex);