mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
shm: Try alternate paths for the socket
This commit is contained in:
parent
73fa2f9b76
commit
7e8eae9f2a
2 changed files with 18 additions and 3 deletions
|
@ -166,6 +166,7 @@ sp_writer_create (const char *path, size_t size, mode_t perms)
|
|||
ShmPipe *self = spalloc_new (ShmPipe);
|
||||
int flags;
|
||||
struct sockaddr_un sun;
|
||||
int i = 0;
|
||||
|
||||
memset (self, 0, sizeof (ShmPipe));
|
||||
|
||||
|
@ -188,12 +189,19 @@ sp_writer_create (const char *path, size_t size, mode_t perms)
|
|||
sun.sun_family = AF_UNIX;
|
||||
strncpy (sun.sun_path, path, sizeof (sun.sun_path));
|
||||
|
||||
if (bind (self->main_socket, (struct sockaddr *) &sun,
|
||||
while (bind (self->main_socket, (struct sockaddr *) &sun,
|
||||
sizeof (struct sockaddr_un)) < 0) {
|
||||
RETURN_ERROR ("bind() failed (%d): %s\n", errno, strerror (errno));
|
||||
if (errno != EADDRINUSE)
|
||||
RETURN_ERROR ("bind() failed (%d): %s\n", errno, strerror (errno));
|
||||
|
||||
if (i > 256)
|
||||
RETURN_ERROR ("Could not find a free socket name for %s", path);
|
||||
|
||||
snprintf (sun.sun_path, sizeof (sun.sun_path), "%s.%d", path, i);
|
||||
i++;
|
||||
}
|
||||
|
||||
self->socket_path = strdup (path);
|
||||
self->socket_path = strdup (sun.sun_path);
|
||||
|
||||
if (listen (self->main_socket, 10) < 0) {
|
||||
RETURN_ERROR ("listen() failed (%d): %s\n", errno, strerror (errno));
|
||||
|
@ -809,3 +817,9 @@ sp_writer_pending_writes (ShmPipe * self)
|
|||
{
|
||||
return (self->buffers != NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
sp_writer_get_path (ShmPipe *pipe)
|
||||
{
|
||||
return pipe->socket_path;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ typedef struct _ShmPipe ShmPipe;
|
|||
typedef struct _ShmBlock ShmBlock;
|
||||
|
||||
ShmPipe *sp_writer_create (const char *path, size_t size, mode_t perms);
|
||||
const char *sp_writer_get_path (ShmPipe *pipe);
|
||||
void sp_close (ShmPipe * self);
|
||||
|
||||
void sp_writer_setperms_shm (ShmPipe * self, mode_t perms);
|
||||
|
|
Loading…
Reference in a new issue