From: Sebastian Harl Date: Wed, 11 Dec 2013 10:26:24 +0000 (+0100) Subject: frontend: Remove stale UNIX sockets before trying to bind(). X-Git-Tag: sysdb-0.1.0~311 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ec6233c810ce2115eb1ce1b3f10d6833f0ed33ea;p=sysdb.git frontend: Remove stale UNIX sockets before trying to bind(). --- diff --git a/src/frontend/sock.c b/src/frontend/sock.c index 4cf1d79..65884ea 100644 --- a/src/frontend/sock.c +++ b/src/frontend/sock.c @@ -104,6 +104,13 @@ open_unix_sock(listener_t *listener) strncpy(sa.sun_path, listener->address + strlen("unix:"), sizeof(sa.sun_path)); + if (unlink(listener->address + strlen("unix:")) && (errno != ENOENT)) { + char errbuf[1024]; + sdb_log(SDB_LOG_WARNING, "frontend: Failed to remove stale UNIX " + "socket %s: %s", listener->address + strlen("unix:"), + sdb_strerror(errno, errbuf, sizeof(errbuf))); + } + status = bind(listener->sock_fd, (struct sockaddr *)&sa, sizeof(sa)); if (status) { char buf[1024];