[angel/core]: remove old unix socket before binding

personal/stbuehler/wip
Stefan Bühler 12 years ago
parent 876261c62c
commit 0247ee879f
  1. 9
      src/angel/angel_plugin_core.c
  2. 10
      src/main/angel_fake.c

@ -485,6 +485,15 @@ static int do_listen(liServer *srv, liSocketAddress *addr, GString *str) {
#endif
#ifdef HAVE_SYS_UN_H
case AF_UNIX:
if (-1 == unlink(addr->addr->un.sun_path)) {
switch (errno) {
case ENOENT:
break;
default:
ERROR(srv, "removing old socket '%s' failed: %s\n", str->str, g_strerror(errno));
return -1;
}
}
if (-1 == (s = socket(AF_UNIX, SOCK_STREAM, 0))) {
ERROR(srv, "Couldn't open socket: %s", g_strerror(errno));
return -1;

@ -21,6 +21,16 @@ int li_angel_fake_listen(liServer *srv, GString *str) {
un->sun_family = AF_UNIX;
strcpy(un->sun_path, str->str + 5);
if (-1 == unlink(un->sun_path)) {
switch (errno) {
case ENOENT:
break;
default:
ERROR(srv, "removing old socket '%s' failed: %s\n", str->str, g_strerror(errno));
g_free(un);
return -1;
}
}
if (-1 == (s = socket(AF_UNIX, SOCK_STREAM, 0))) {
ERROR(srv, "Couldn't open socket: %s", g_strerror(errno));
g_free(un);

Loading…
Cancel
Save