Browse Source

Better isolation of server and clients system resources to allow starting the server in several user account at the same time.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3094 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.1
sletz 15 years ago
parent
commit
a7fd397819
15 changed files with 46 additions and 28 deletions
  1. +4
    -0
      ChangeLog
  2. +15
    -10
      common/shm.c
  3. +1
    -0
      linux/alsa/JackAlsaDriver.cpp
  4. +1
    -0
      linux/firewire/JackFFADODriver.cpp
  5. +1
    -0
      linux/freebob/JackFreebobDriver.cpp
  6. +3
    -2
      macosx/JackMachClientChannel.cpp
  7. +2
    -1
      macosx/JackMachSemaphore.cpp
  8. +2
    -1
      macosx/JackMachServerChannel.cpp
  9. +2
    -1
      macosx/JackMachServerNotifyChannel.cpp
  10. +2
    -5
      posix/JackFifo.cpp
  11. +2
    -1
      posix/JackPosixSemaphore.cpp
  12. +6
    -5
      posix/JackSocket.cpp
  13. +2
    -1
      windows/JackWinEvent.cpp
  14. +2
    -1
      windows/JackWinSemaphore.cpp
  15. +1
    -0
      windows/portaudio/JackPortAudioDriver.cpp

+ 4
- 0
ChangeLog View File

@@ -23,6 +23,10 @@ Michael Voigt
Jackdmp changes log
---------------------------

2008-11-31 Stephane Letz <letz@grame.fr>

* Better isolation of server and clients system resources to allow starting the server in several user account at the same time.

2008-11-19 Stephane Letz <letz@grame.fr>

* Libjack shutdown handler does not "deactivate" (fActive = false) the client anymore, so that jack_deactivate correctly does the job later on.


+ 15
- 10
common/shm.c View File

@@ -32,7 +32,7 @@
*/

#include "JackConstants.h"
#ifdef WIN32
#include <process.h>
#else
@@ -57,6 +57,17 @@
#include "shm.h"
#include "JackError.h"

static int GetUID()
{
#ifdef WIN32
return _getpid();
//#error "No getuid function available"
#else
return getuid();
#endif
}


#ifdef USE_POSIX_SHM
static jack_shmtype_t jack_shmtype = shm_POSIX;
#elif WIN32
@@ -263,14 +274,8 @@ jack_shm_validate_registry ()
static void
jack_set_server_prefix (const char *server_name)
{
#ifdef WIN32
snprintf (jack_shm_server_prefix, sizeof (jack_shm_server_prefix),
"jack-%d:%s:", _getpid (), server_name); // steph TO CHECK
#else
snprintf (jack_shm_server_prefix, sizeof (jack_shm_server_prefix),
"/jack-%d:%s:", getuid (), server_name);
#endif

"jack-%d:%s:", GetUID(), server_name);
}

/* gain server addressability to shared memory registration segment
@@ -770,7 +775,7 @@ jack_shmalloc (const char *shm_name, jack_shmsize_t size, jack_shm_info_t* si)
* registry index for uniqueness and ignore the shm_name
* parameter. Bah!
*/
snprintf (name, sizeof (name), "/jackmp-%d", registry->index);
snprintf (name, sizeof (name), "/jack-%d-%d", GetUID(), registry->index);

if (strlen (name) >= sizeof (registry->id)) {
jack_error ("shm segment name too long %s", name);
@@ -959,7 +964,7 @@ jack_shmalloc (const char *shm_name, jack_shmsize_t size, jack_shm_info_t* si)
goto unlock;
}

snprintf (name, sizeof (name), "jack-%d", registry->index);
snprintf (name, sizeof (name), "jack-%d-%d", GetUID(), registry->index);

if (strlen (name) >= sizeof (registry->id)) {
jack_error ("shm segment name too long %s", name);


+ 1
- 0
linux/alsa/JackAlsaDriver.cpp View File

@@ -2262,6 +2262,7 @@ int JackAlsaDriver::Open(jack_nframes_t nframes,
fPlaybackChannels = ((alsa_driver_t *)fDriver)->playback_nchannels;
return 0;
} else {
JackAudioDriver::Close();
return -1;
}
}


+ 1
- 0
linux/firewire/JackFFADODriver.cpp View File

@@ -695,6 +695,7 @@ int JackFFADODriver::Open(ffado_jack_settings_t *params)
//fPlaybackChannels = ((ffado_driver_t *)fDriver)->playback_nchannels_audio;
return 0;
} else {
JackAudioDriver::Close();
return -1;
}
}


+ 1
- 0
linux/freebob/JackFreebobDriver.cpp View File

@@ -827,6 +827,7 @@ int JackFreebobDriver::Open(freebob_jack_settings_t *params)
fPlaybackChannels = ((freebob_driver_t *)fDriver)->playback_nchannels_audio;
return 0;
} else {
JackAudioDriver::Close();
return -1;
}
}


+ 3
- 2
macosx/JackMachClientChannel.cpp View File

@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#include "JackMachClientChannel.h"
#include "JackRPCEngine.h"
#include "JackTools.h"
#include "JackRPCClientServer.c"
#include "JackError.h"
#include "JackLibClient.h"
@@ -43,7 +44,7 @@ int JackMachClientChannel::ServerCheck(const char* server_name)
{
jack_log("JackMachClientChannel::ServerCheck = %s", server_name);
char jack_server_entry_name[512];
snprintf(jack_server_entry_name, sizeof(jack_server_entry_name), "%s_%s", jack_server_entry, server_name);
snprintf(jack_server_entry_name, sizeof(jack_server_entry_name), "%s.%d_%s", jack_server_entry, JackTools::GetUID(), server_name);

// Connect to server
if (!fServerPort.ConnectPort(jack_server_entry_name)) {
@@ -58,7 +59,7 @@ int JackMachClientChannel::Open(const char* server_name, const char* name, char*
{
jack_log("JackMachClientChannel::Open name = %s", name);
char jack_server_entry_name[512];
snprintf(jack_server_entry_name, sizeof(jack_server_entry_name), "%s_%s", jack_server_entry, server_name);
snprintf(jack_server_entry_name, sizeof(jack_server_entry_name), "%s.%d_%s", jack_server_entry, JackTools::GetUID(), server_name);

// Connect to server
if (!fServerPort.ConnectPort(jack_server_entry_name)) {


+ 2
- 1
macosx/JackMachSemaphore.cpp View File

@@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "JackMachSemaphore.h"
#include "JackTools.h"
#include "JackError.h"
#include <stdio.h>

@@ -28,7 +29,7 @@ mach_port_t JackMachSemaphore::fBootPort = 0;

void JackMachSemaphore::BuildName(const char* name, const char* server_name, char* res)
{
sprintf(res, "jack_mach_sem.%s_%s", server_name, name);
sprintf(res, "jack_mach_sem.%d_%s_%s", JackTools::GetUID(), server_name, name);
}

bool JackMachSemaphore::Signal()


+ 2
- 1
macosx/JackMachServerChannel.cpp View File

@@ -17,6 +17,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

*/

#include "JackTools.h"
#include "JackMachServerChannel.h"
#include "JackRPCEngineServer.c"
#include "JackError.h"
@@ -41,7 +42,7 @@ int JackMachServerChannel::Open(const char* server_name, JackServer* server)
{
jack_log("JackMachServerChannel::Open");
char jack_server_entry_name[512];
snprintf(jack_server_entry_name, sizeof(jack_server_entry_name), "%s_%s", jack_server_entry, server_name);
snprintf(jack_server_entry_name, sizeof(jack_server_entry_name), "%s.%d_%s", jack_server_entry, JackTools::GetUID(), server_name);

if (!fServerPort.AllocatePort(jack_server_entry_name, 16)) { // 16 is the max possible value
jack_error("Cannot check in Jack server");


+ 2
- 1
macosx/JackMachServerNotifyChannel.cpp View File

@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#include "JackMachServerNotifyChannel.h"
#include "JackRPCEngineUser.c"
#include "JackTools.h"
#include "JackConstants.h"
#include "JackError.h"
#include <stdio.h>
@@ -30,7 +31,7 @@ int JackMachServerNotifyChannel::Open(const char* server_name)
{
jack_log("JackMachServerChannel::Open");
char jack_server_entry_name[512];
snprintf(jack_server_entry_name, sizeof(jack_server_entry_name), "%s_%s", jack_server_entry, server_name);
snprintf(jack_server_entry_name, sizeof(jack_server_entry_name), "%s.%d_%s", jack_server_entry, JackTools::GetUID(), server_name);

if (!fClientPort.ConnectPort(jack_server_entry_name)) {
jack_error("Cannot connect to server port");


+ 2
- 5
posix/JackFifo.cpp View File

@@ -17,11 +17,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

*/

#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif

#include "JackFifo.h"
#include "JackTools.h"
#include "JackError.h"
#include "JackConstants.h"
#include <sys/types.h>
@@ -35,7 +32,7 @@ namespace Jack

void JackFifo::BuildName(const char* name, const char* server_name, char* res)
{
sprintf(res, "%s/jack_fifo.%s_%s", jack_client_dir, server_name, name);
sprintf(res, "%s/jack_fifo.%d_%s_%s", jack_client_dir, JackTools::GetUID(), server_name, name);
}

bool JackFifo::Signal()


+ 2
- 1
posix/JackPosixSemaphore.cpp View File

@@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "JackPosixSemaphore.h"
#include "JackTools.h"
#include "JackConstants.h"
#include "JackError.h"
#include <fcntl.h>
@@ -29,7 +30,7 @@ namespace Jack

void JackPosixSemaphore::BuildName(const char* name, const char* server_name, char* res)
{
sprintf(res, "jack_sem.%s_%s", server_name, name);
sprintf(res, "jack_sem.%d_%s_%s", JackTools::GetUID(), server_name, name);
}

bool JackPosixSemaphore::Signal()


+ 6
- 5
posix/JackSocket.cpp View File

@@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "JackSocket.h"
#include "JackTools.h"
#include "JackError.h"
#include <string.h>
#include <stdio.h>
@@ -67,7 +68,7 @@ int JackClientSocket::Connect(const char* dir, const char* name, int which) // A
}

addr.sun_family = AF_UNIX;
snprintf(addr.sun_path, sizeof(addr.sun_path) - 1, "%s/jack_%s_%d", dir, name, which);
snprintf(addr.sun_path, sizeof(addr.sun_path) - 1, "%s/jack_%s_%d_%d", dir, name, JackTools::GetUID(), which);
jack_log("Connect: addr.sun_path %s", addr.sun_path);

if (connect(fSocket, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
@@ -96,7 +97,7 @@ int JackClientSocket::Connect(const char* dir, int which)
}

addr.sun_family = AF_UNIX;
snprintf(addr.sun_path, sizeof(addr.sun_path) - 1, "%s/jack_%d", dir, which);
snprintf(addr.sun_path, sizeof(addr.sun_path) - 1, "%s/jack_%d_%d", dir, JackTools::GetUID(), which);
jack_log("Connect: addr.sun_path %s", addr.sun_path);

if (connect(fSocket, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
@@ -170,7 +171,7 @@ int JackServerSocket::Bind(const char* dir, const char* name, int which) // A re
addr.sun_family = AF_UNIX;

// TO CORRECT: always reuse the same name for now...
snprintf(fName, sizeof(addr.sun_path) - 1, "%s/jack_%s_%d", dir, name, which);
snprintf(fName, sizeof(addr.sun_path) - 1, "%s/jack_%s_%d_%d", dir, name, JackTools::GetUID(), which);
strncpy(addr.sun_path, fName, sizeof(addr.sun_path) - 1);
/*
if (access(addr.sun_path, F_OK) == 0) {
@@ -221,7 +222,7 @@ int JackServerSocket::Bind(const char* dir, int which) // A revoir : utilisation
*/

// TO CORRECT: always reuse the same name for now...
snprintf(fName, sizeof(addr.sun_path) - 1, "%s/jack_%d", dir, which);
snprintf(fName, sizeof(addr.sun_path) - 1, "%s/jack_%d_%d", dir, JackTools::GetUID(), which);
strncpy(addr.sun_path, fName, sizeof(addr.sun_path) - 1);
/*
if (access(addr.sun_path, F_OK) == 0) {
@@ -258,7 +259,7 @@ JackClientSocket* JackServerSocket::Accept()
memset(&client_addr, 0, sizeof(client_addr));
client_addrlen = sizeof(client_addr);

int fd = accept(fSocket, (struct sockaddr*) & client_addr, &client_addrlen);
int fd = accept(fSocket, (struct sockaddr*)&client_addr, &client_addrlen);
if (fd < 0) {
jack_error("Cannot accept new connection err = %s", strerror(errno));
return 0;


+ 2
- 1
windows/JackWinEvent.cpp View File

@@ -18,6 +18,7 @@ This program is free software; you can redistribute it and/or modify
*/

#include "JackWinEvent.h"
#include "JackTools.h"
#include "JackError.h"
#include <assert.h>

@@ -29,7 +30,7 @@ namespace Jack

void JackWinEvent::BuildName(const char* name, const char* server_name, char* res)
{
sprintf(res, "jack_pipe.%s_%s", server_name, name);
sprintf(res, "jack_pipe.%d_%s_%s", JackTools::GetUID(), server_name, name);
}

bool JackWinEvent::Signal()


+ 2
- 1
windows/JackWinSemaphore.cpp View File

@@ -18,6 +18,7 @@ This program is free software; you can redistribute it and/or modify
*/

#include "JackWinSemaphore.h"
#include "JackTools.h"
#include "JackError.h"
#include <stdio.h>

@@ -26,7 +27,7 @@ namespace Jack

void JackWinSemaphore::BuildName(const char* name, const char* server_name, char* res)
{
sprintf(res, "jack_pipe.%s_%s", server_name, name);
sprintf(res, "jack_pipe.%d_%s_%s", JackTools::GetUID(), server_name, name);
}

bool JackWinSemaphore::Signal()


+ 1
- 0
windows/portaudio/JackPortAudioDriver.cpp View File

@@ -173,6 +173,7 @@ namespace Jack
return 0;

error:
JackAudioDriver::Close();
jack_error ( "Can't open default PortAudio device : %s", Pa_GetErrorText(err) );
return -1;
}


Loading…
Cancel
Save