Do not remove existing socket file
Check for its presence and bail out if found. If the socket file is present, either a server is already bound to it, or the last one errored out and we'd want to inspect this. Also it could be an unrelated file given by error.
This commit is contained in:
parent
d2223ba259
commit
ecb0d9e54e
1 changed files with 6 additions and 3 deletions
9
quark.c
9
quark.c
|
@ -938,10 +938,8 @@ getusock(char *udsname, uid_t uid, gid_t gid)
|
||||||
}
|
}
|
||||||
memcpy(addr.sun_path, udsname, udsnamelen + 1);
|
memcpy(addr.sun_path, udsname, udsnamelen + 1);
|
||||||
|
|
||||||
unlink(udsname);
|
|
||||||
|
|
||||||
if (bind(insock, (const struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
if (bind(insock, (const struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
||||||
die("%s: bind: %s\n", argv0, strerror(errno));
|
die("%s: bind %s: %s\n", argv0, udsname, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listen(insock, SOMAXCONN) < 0) {
|
if (listen(insock, SOMAXCONN) < 0) {
|
||||||
|
@ -1017,6 +1015,11 @@ main(int argc, char *argv[])
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (udsname && (!access(udsname, F_OK) || errno != ENOENT)) {
|
||||||
|
die("%s: socket file: %s\n",
|
||||||
|
argv0, errno ? strerror(errno) : "file exists");
|
||||||
|
}
|
||||||
|
|
||||||
/* compile and check the supplied vhost regexes */
|
/* compile and check the supplied vhost regexes */
|
||||||
if (vhosts) {
|
if (vhosts) {
|
||||||
for (i = 0; i < LEN(vhost); i++) {
|
for (i = 0; i < LEN(vhost); i++) {
|
||||||
|
|
Loading…
Reference in a new issue