summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 45226d3)
raw | patch | inline | side by side (parent: 45226d3)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 27 Apr 2014 14:53:50 +0000 (16:53 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 27 Apr 2014 14:53:50 +0000 (16:53 +0200) |
src/frontend/sock.c | patch | blob | history |
diff --git a/src/frontend/sock.c b/src/frontend/sock.c
index 90aeab1406a6a6389f8ce083dbab72a624b4a936..2e5a6aff66d6484831907c1bcc31fb0b7dd698cb 100644 (file)
--- a/src/frontend/sock.c
+++ b/src/frontend/sock.c
static int
open_unix_sock(listener_t *listener)
{
+ const char *addr;
struct sockaddr_un sa;
int status;
return -1;
}
+ if (*listener->address == '/')
+ addr = listener->address;
+ else
+ addr = listener->address + strlen("unix:");
+
memset(&sa, 0, sizeof(sa));
sa.sun_family = AF_UNIX;
- strncpy(sa.sun_path, listener->address + strlen("unix:"),
- sizeof(sa.sun_path));
+ strncpy(sa.sun_path, addr, sizeof(sa.sun_path));
- if (unlink(listener->address + strlen("unix:")) && (errno != ENOENT)) {
+ if (unlink(addr) && (errno != ENOENT)) {
char errbuf[1024];
sdb_log(SDB_LOG_WARNING, "frontend: Failed to remove stale UNIX "
"socket %s: %s", listener->address + strlen("unix:"),
static void
close_unix_sock(listener_t *listener)
{
+ const char *addr;
assert(listener);
+
if (! listener->address)
return;
+ if (*listener->address == '/')
+ addr = listener->address;
+ else
+ addr = listener->address + strlen("unix:");
+
if (listener->sock_fd >= 0)
close(listener->sock_fd);
listener->sock_fd = -1;
- unlink(listener->address + strlen("unix:"));
+ unlink(addr);
} /* close_unix_sock */
/*
/* the enum has to be sorted the same as the implementations array
* to ensure that the type may be used as index into the array */
enum {
- LISTENER_UNIXSOCK = 0,
+ LISTENER_UNIXSOCK = 0, /* this is the default */
};
static fe_listener_impl_t listener_impls[] = {
{ LISTENER_UNIXSOCK, "unix", open_unix_sock, close_unix_sock },
sep = strchr(address, (int)':');
if (! sep)
- return -1;
+ return listener_impls[0].type;
assert(sep > address);
len = (size_t)(sep - address);