Skip to content

Commit

Permalink
remove unix socket before binding
Browse files Browse the repository at this point in the history
  • Loading branch information
yrutschle committed Dec 23, 2024
1 parent bf08229 commit 2e9f23a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion common.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,17 @@ static int start_listen_unix(struct listen_endpoint *sockfd[], int num_addr, str
int fd = socket(AF_UNIX, cfg->is_udp ? SOCK_DGRAM : SOCK_STREAM, 0);
CHECK_RES_DIE(fd, "socket(AF_UNIX)");

int res = unlink(cfg->host);
if ((res == -1) && (errno != ENOENT)) {
print_message(msg_config_error, "unlink unix socket `%s':%d:%s\n", cfg->host, errno, strerror(errno));
exit(4);
}

struct sockaddr_un sun;
sun.sun_family = AF_UNIX;
strncpy(sun.sun_path, cfg->host, sizeof(sun.sun_path)-1);
printf("binding [%s]\n", sun.sun_path);
int res = bind(fd, (struct sockaddr*)&sun, sizeof(sun));
res = bind(fd, (struct sockaddr*)&sun, sizeof(sun));
CHECK_RES_DIE(res, "bind(AF_UNIX)");

res = listen(fd, 50);
Expand Down
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef VERSION_H
#define VERSION_H

#define VERSION "v2.1.4-24-g59d89e3-dirty"
#define VERSION "v2.1.4-25-gbf08229-dirty"
#endif

0 comments on commit 2e9f23a

Please sign in to comment.