Skip to content

Commit

Permalink
Don't unlink the ipc socket when not needed
Browse files Browse the repository at this point in the history
I never managed to catch the obvious and silly error since the unlink call
always failed with EPERM.
Also, the ipc socket suffix has been changed to '.socket' to reflect the
undeniable fact that it's a unix socket.
  • Loading branch information
LemonBoy committed Jul 30, 2015
1 parent b392ca9 commit e1e1631
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ipc.c
Expand Up @@ -6,7 +6,7 @@
#include <sys/socket.h>
#include <sys/un.h>

#define IPC_SOCKET "/run/ldm.fifo"
#define IPC_SOCKET "/run/ldm.socket"

void
ipc_deinit (int fd)
Expand All @@ -29,14 +29,14 @@ ipc_init (int as_master)
return -1;
}

// Make sure that there are no leftovers
unlink (IPC_SOCKET);

memset(&so, 0, sizeof(struct sockaddr_un));
so.sun_family = AF_UNIX;
strncpy(so.sun_path, IPC_SOCKET, sizeof(so.sun_path));

if (as_master) {
// Make sure that there are no leftovers
unlink (IPC_SOCKET);

// The master waits for the slaves to connect
if (bind(sock, (struct sockaddr *)&so, sizeof(struct sockaddr_un)) < 0) {
perror("bind");
Expand Down

0 comments on commit e1e1631

Please sign in to comment.