remove unix socket before binding

This commit is contained in:
Yves Rutschle 2024-12-23 17:25:40 +01:00
parent bf082292c2
commit 2e9f23a2f4
2 changed files with 8 additions and 2 deletions

View File

@ -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);

View File

@ -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