From 713e8dfdb2339874e4e68d8830be1caffd43e724 Mon Sep 17 00:00:00 2001 From: sletz Date: Fri, 5 Sep 2008 15:35:05 +0000 Subject: [PATCH] Ugly temporary fix for netmanager deadlock. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2882 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackNetInterface.cpp | 6 ++++++ posix/JackPosixThread.cpp | 7 +++++++ posix/JackPosixThread.h | 3 ++- windows/JackWinThread.cpp | 7 +++++++ windows/JackWinThread.h | 2 ++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/common/JackNetInterface.cpp b/common/JackNetInterface.cpp index 286fc08b..9fc7a3f7 100644 --- a/common/JackNetInterface.cpp +++ b/common/JackNetInterface.cpp @@ -19,6 +19,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "JackNetInterface.h" #include "JackException.h" +#include "JackPlatformPlug.h" using namespace std; @@ -284,6 +285,7 @@ namespace Jack //stop process fRunning = false; + //send a 'multicast euthanasia request' - new socket is required on macosx jack_info ( "Exiting '%s'", fParams.fName ); SetPacketType ( &fParams, KILL_MASTER ); @@ -293,6 +295,9 @@ namespace Jack if ( mcast_socket.SendTo ( &fParams, sizeof ( session_params_t ), 0, fMulticastIP ) == SOCKET_ERROR ) jack_error ( "Can't send suicide request : %s", StrError ( NET_ERROR_CODE ) ); mcast_socket.Close(); + + // UGLY temporary way to be sure the thread does not call code possibly causing a deadlock in JackEngine. + ThreadExit(); } int JackNetMasterInterface::Send ( size_t size, int flags ) @@ -487,6 +492,7 @@ namespace Jack case 's': //sync if ( rx_head->fCycle == fTxHeader.fCycle ) return 0; + break; } } } diff --git a/posix/JackPosixThread.cpp b/posix/JackPosixThread.cpp index 0427b059..821cad2e 100644 --- a/posix/JackPosixThread.cpp +++ b/posix/JackPosixThread.cpp @@ -261,6 +261,13 @@ void JackPosixThread::Terminate() pthread_exit(0); } +void ThreadExit() +{ + jack_log("ThreadExit"); + pthread_exit(0); +} + + } // end of namespace EXPORT bool jack_tls_allocate_key(jack_tls_key *key_ptr) diff --git a/posix/JackPosixThread.h b/posix/JackPosixThread.h index 6408112e..00cdb57f 100644 --- a/posix/JackPosixThread.h +++ b/posix/JackPosixThread.h @@ -69,9 +69,10 @@ class EXPORT JackPosixThread : public detail::JackThreadInterface static int StartImp(pthread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg); static int StopImp(pthread_t thread); static int KillImp(pthread_t thread); - }; +void ThreadExit(); + } // end of namespace diff --git a/windows/JackWinThread.cpp b/windows/JackWinThread.cpp index 03ea77d0..b9e064b4 100644 --- a/windows/JackWinThread.cpp +++ b/windows/JackWinThread.cpp @@ -224,6 +224,13 @@ pthread_t JackWinThread::GetThreadID() void JackWinThread::Terminate() { + jack_log("JackWinThread::Terminate"); + ExitThread(0); +} + +void ThreadExit() +{ + jack_log("ThreadExit"); ExitThread(0); } diff --git a/windows/JackWinThread.h b/windows/JackWinThread.h index dd71cdb5..a56968fd 100644 --- a/windows/JackWinThread.h +++ b/windows/JackWinThread.h @@ -71,6 +71,8 @@ class EXPORT JackWinThread : public detail::JackThreadInterface }; +void ThreadExit(); + } // end of namespace #endif