diff options
author | sletz <sletz@0c269be4-1314-0410-8aa9-9f06e86f4224> | 2011-10-28 14:02:59 +0000 |
---|---|---|
committer | sletz <sletz@0c269be4-1314-0410-8aa9-9f06e86f4224> | 2011-10-28 14:02:59 +0000 |
commit | b0faf2a03fae0a4164fa58bea798ede39a4b1f5b (patch) | |
tree | c5c02e1c1765541acdea69734f61e697d332e3da /common/shm.c | |
parent | 7f510d8bf45bcec139a45b64652057a384787a57 (diff) | |
download | jack2-b0faf2a03fae0a4164fa58bea798ede39a4b1f5b.tar.gz |
Correct multi server launch bug on Windows.
git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4557 0c269be4-1314-0410-8aa9-9f06e86f4224
Diffstat (limited to 'common/shm.c')
-rw-r--r-- | common/shm.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/common/shm.c b/common/shm.c index c8079202..5a05103e 100644 --- a/common/shm.c +++ b/common/shm.c @@ -141,28 +141,31 @@ static char jack_shm_server_prefix[JACK_SERVER_NAME_SIZE] = ""; static int semid = -1; -#ifdef WIN32 - -static bool check_process_running(DWORD process_id) -{ - DWORD aProcesses [2048], cbNeeded, cProcesses; +#ifdef WIN32
+
+#include <psapi.h>
+#include <lmcons.h> + +static BOOL check_process_running(DWORD process_id) +{
+ DWORD aProcesses[2048], cbNeeded, cProcesses; unsigned int i; // Enumerate all processes if (!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded)) { - return false; + return FALSE; } // Calculate how many process identifiers were returned. cProcesses = cbNeeded / sizeof(DWORD); - for (i = 0; i < cProcesses; i++) { - if (aProcesses [i] == dwProcessID) { + for (i = 0; i < cProcesses; i++) {
+ if (aProcesses[i] == process_id) { // Process process_id is running... - return true; + return TRUE; } } - return false; + return FALSE; } static int @@ -310,9 +313,18 @@ jack_shm_validate_registry () */ static void jack_set_server_prefix (const char *server_name) -{ - snprintf (jack_shm_server_prefix, sizeof (jack_shm_server_prefix), - "jack-%d:%s:", GetUID(), server_name); +{
+ #ifdef WIN32
+ char buffer[UNLEN+1]={0};
+ DWORD len = UNLEN+1;
+ GetUserName(buffer, &len);
+ snprintf (jack_shm_server_prefix, sizeof (jack_shm_server_prefix), + "jack-%s:%s:", buffer, server_name);
+ #else
+ snprintf (jack_shm_server_prefix, sizeof (jack_shm_server_prefix), + "jack-%d:%s:", GetUID(), server_name);
+ #endif + } /* gain server addressability to shared memory registration segment @@ -490,7 +502,7 @@ jack_register_server (const char *server_name, int new_registry) /* See if server_name already registered. Since server names * are per-user, we register the unique server prefix string. */ - for (i = 0; i < MAX_SERVERS; i++) { + for (i = 0; i < MAX_SERVERS; i++) {
if (strncmp (jack_shm_header->server[i].name, jack_shm_server_prefix, @@ -535,7 +547,7 @@ jack_register_server (const char *server_name, int new_registry) jack_shm_header->server[i].pid = GetPID(); strncpy (jack_shm_header->server[i].name, jack_shm_server_prefix, - JACK_SERVER_NAME_SIZE); + JACK_SERVER_NAME_SIZE);
unlock: jack_shm_unlock_registry (); @@ -599,7 +611,7 @@ jack_cleanup_shm () /* see if allocator still exists */ #ifdef WIN32 // steph - jack_info("TODO: kill API not available !!"); + //jack_info("TODO: kill API not available !!"); #else if (kill (r->allocator, 0)) { if (errno == ESRCH) { |