Commit 18dd612f authored by sletz's avatar sletz
Browse files

Client incorrect re-naming fixed: now done at socket level also.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3424 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 0ce4b472
......@@ -17,39 +17,43 @@ Nedko Arnaudov
Fernando Lopez-Lezcano
Romain Moret
Florian Faber
Michael Voigt
Michael Voigt
Torben Hohn
---------------------------
Jackdmp changes log
---------------------------
2009-03-11 Stephane Letz <letz@grame.fr>
* Client incorrect re-naming fixed: now done at socket level also.
2009-03-10 Stephane Letz <letz@grame.fr>
* Add -g (ring-buffer) parameter to netadapter.
* Automatic adaptative ringbuffer size mode when -g = 0.
* Add -g (ring-buffer) parameter to netadapter.
* Automatic adaptative ringbuffer size mode when -g = 0.
2009-03-09 Stephane Letz <letz@grame.fr>
* Use Torben Hohn PI controler code for adapters (in progress).
* Use Torben Hohn PI controler code for adapters (in progress).
2009-03-05 Stephane Letz <letz@grame.fr>
* Support for BIG_ENDIAN machines in NetJack2 for transport data.
* Support for BIG_ENDIAN machines in NetJack2 for transport data.
* Add auto_connect parameter in netmanager and netadapter.
2009-03-03 Stephane Letz <letz@grame.fr>
* More robust profiling tools when clients come and go.
2009-03-01 Stephane Letz <letz@grame.fr>
* Raise default port number to 1024.
2009-02-27 Stephane Letz <letz@grame.fr>
* Improve generated gnuplot files for adapting code.
2009-02-25 Stephane Letz <letz@grame.fr>
* Major cleanup in adapter code.
......@@ -58,8 +62,8 @@ Torben Hohn
* Fix JackNetDriver::Close method.
* For audio device reservation, add card_to_num function.
* Fix buffer size and sample rate handling in JackAlsaAdapter.
* Add control for adapter ringbuffer size.
* Fix buffer size and sample rate handling in JackAlsaAdapter.
* Add control for adapter ringbuffer size.
* Fix JackAlsaAdapter.h for 64 bits compilation.
2009-02-23 Stephane Letz <letz@grame.fr>
......
......@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
namespace Jack
{
#define TIME_POINTS 125000
#define TIME_POINTS 100000
#define FAILURE_TIME_POINTS 10000
#define FAILURE_WINDOW 10
#define MEASURED_CLIENTS 32
......
......@@ -30,9 +30,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
namespace Jack
{
void JackFifo::BuildName(const char* name, const char* server_name, char* res)
void JackFifo::BuildName(const char* client_name, const char* server_name, char* res)
{
sprintf(res, "%s/jack_fifo.%d_%s_%s", jack_client_dir, JackTools::GetUID(), server_name, name);
char ext_client_name[JACK_CLIENT_NAME_SIZE + 1];
JackTools::RewriteName(client_name, ext_client_name);
sprintf(res, "%s/jack_fifo.%d_%s_%s", jack_client_dir, JackTools::GetUID(), server_name, ext_client_name);
}
bool JackFifo::Signal()
......
......@@ -29,6 +29,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
namespace Jack
{
static void BuildName(const char* client_name, char* res, const char* dir, int which)
{
char ext_client_name[JACK_CLIENT_NAME_SIZE + 1];
JackTools::RewriteName(client_name, ext_client_name);
sprintf(res, "%s/jack_%s_%d_%d", dir, ext_client_name, JackTools::GetUID(), which);
}
JackClientSocket::JackClientSocket(int socket): fSocket(socket),fTimeOut(0)
{}
......@@ -112,36 +119,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_%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) {
jack_error("Cannot connect to server socket err = %s", strerror(errno));
close(fSocket);
return -1;
}
#ifdef __APPLE__
int on = 1 ;
if (setsockopt(fSocket, SOL_SOCKET, SO_NOSIGPIPE, (const char*)&on, sizeof(on)) < 0) {
jack_log("setsockopt SO_NOSIGPIPE fd = %ld err = %s", fSocket, strerror(errno));
}
#endif
return 0;
}
int JackClientSocket::Connect(const char* dir, int which)
{
struct sockaddr_un addr;
if ((fSocket = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
jack_error("Cannot create socket err = %s", strerror(errno));
return -1;
}
addr.sun_family = AF_UNIX;
snprintf(addr.sun_path, sizeof(addr.sun_path) - 1, "%s/jack_%d_%d", dir, JackTools::GetUID(), which);
BuildName(name, addr.sun_path, dir, which);
jack_log("Connect: addr.sun_path %s", addr.sun_path);
if (connect(fSocket, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
......@@ -271,67 +249,9 @@ 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_%d", dir, name, JackTools::GetUID(), which);
BuildName(name, fName, dir, which);
strncpy(addr.sun_path, fName, sizeof(addr.sun_path) - 1);
/*
if (access(addr.sun_path, F_OK) == 0) {
goto error;
}
*/
jack_log("Bind: addr.sun_path %s", addr.sun_path);
unlink(fName); // Security...
if (bind(fSocket, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
jack_error("Cannot bind server to socket err = %s", strerror(errno));
goto error;
}
if (listen(fSocket, 1) < 0) {
jack_error("Cannot enable listen on server socket err = %s", strerror(errno));
goto error;
}
return 0;
error:
unlink(fName);
close(fSocket);
return -1;
}
int JackServerSocket::Bind(const char* dir, int which) // A revoir : utilisation de "which"
{
struct sockaddr_un addr;
if ((fSocket = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
jack_error("Cannot create server socket err = %s", strerror(errno));
return -1;
}
addr.sun_family = AF_UNIX;
/*
for (int i = 0; i < 999; i++) {
snprintf(addr.sun_path, sizeof(addr.sun_path) - 1,"%s/jack_%d", dir, i);
snprintf(fName, sizeof(addr.sun_path) - 1,"%s/jack_%d", dir, i);
if (access(addr.sun_path, F_OK) != 0) {
break;
}
}
*/
// TO CORRECT: always reuse the same name for now...
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) {
goto error;
}
*/
jack_log("Bind: addr.sun_path %s", addr.sun_path);
unlink(fName); // Security...
......
......@@ -50,7 +50,6 @@ class JackClientSocket
{}
JackClientSocket(int socket);
int Connect(const char* dir, int which);
int Connect(const char* dir, const char* name, int which);
int Close();
int Read(void* data, int len);
......@@ -69,13 +68,16 @@ class JackClientSocket
\brief Server socket.
*/
#define SOCKET_MAX_NAME_SIZE 256
class JackServerSocket
{
private:
int fSocket;
char fName[256];
char fName[SOCKET_MAX_NAME_SIZE];
public:
......@@ -84,7 +86,6 @@ class JackServerSocket
~JackServerSocket()
{}
int Bind(const char* dir, int which);
int Bind(const char* dir, const char* name, int which);
JackClientSocket* Accept();
int Close();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment