From 780e0439a372e733b2624ccd3f0f08b0be02c08f Mon Sep 17 00:00:00 2001 From: sletz Date: Wed, 13 May 2009 16:19:05 +0000 Subject: [PATCH] Reworked Torben Hohn fix for server restart issue on Windows. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3537 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 4 ++++ windows/JackWinNamedPipeClientChannel.cpp | 5 +++-- windows/JackWinSemaphore.cpp | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1ef571c..78bc7695 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,10 @@ Paul Davis Jackdmp changes log --------------------------- +2009-05-13 Stephane Letz + + * Reworked Torben Hohn fix for server restart issue on Windows. + 2009-05-11 Stephane Letz * New jack_free function added in jack.h. diff --git a/windows/JackWinNamedPipeClientChannel.cpp b/windows/JackWinNamedPipeClientChannel.cpp index 35755b45..b36f03e1 100644 --- a/windows/JackWinNamedPipeClientChannel.cpp +++ b/windows/JackWinNamedPipeClientChannel.cpp @@ -311,7 +311,6 @@ bool JackWinNamedPipeClientChannel::Execute() JackResult res; if (event.Read(&fNotificationListenPipe) < 0) { - fNotificationListenPipe.Close(); jack_error("JackWinNamedPipeClientChannel read fail"); goto error; } @@ -320,7 +319,6 @@ bool JackWinNamedPipeClientChannel::Execute() if (event.fSync) { if (res.Write(&fNotificationListenPipe) < 0) { - fNotificationListenPipe.Close(); jack_error("JackWinNamedPipeClientChannel write fail"); goto error; } @@ -328,6 +326,9 @@ bool JackWinNamedPipeClientChannel::Execute() return true; error: + // Close the pipes, server wont be able to create them otherwise. + fNotificationListenPipe.Close(); + fRequestPipe.Close(); fClient->ShutDown(); return false; } diff --git a/windows/JackWinSemaphore.cpp b/windows/JackWinSemaphore.cpp index 88236d49..8ce52d62 100644 --- a/windows/JackWinSemaphore.cpp +++ b/windows/JackWinSemaphore.cpp @@ -137,9 +137,9 @@ bool JackWinSemaphore::Allocate(const char* name, const char* server_name, int v return false; } else if (GetLastError() == ERROR_ALREADY_EXISTS) { jack_error("Allocate: named semaphore already exist name = %s", fName); - CloseHandle(fSemaphore); - fSemaphore = NULL; - return false; + // Try to open it + fSemaphore = OpenSemaphore(SEMAPHORE_ALL_ACCESS, FALSE, fName); + return (fSemaphore != NULL); } else { return true; }