summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 92860d6)
raw | patch | inline | side by side (parent: 92860d6)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Thu, 20 Oct 2016 14:24:14 +0000 (20:24 +0600) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Thu, 20 Oct 2016 14:24:14 +0000 (20:24 +0600) |
Show socket path in log messages.
Closes: #1995
Closes: #1995
src/powerdns.c | patch | blob | history |
diff --git a/src/powerdns.c b/src/powerdns.c
index 7e9e8747cb6e8b2bc5e36ec9b496bb06af5b02cc..d7aa4e9dbe8ea8d94ca739baa2750b1d2026a707 100644 (file)
--- a/src/powerdns.c
+++ b/src/powerdns.c
# define UNIX_PATH_MAX sizeof (((struct sockaddr_un *)0)->sun_path)
#endif
#define FUNC_ERROR(func) do { char errbuf[1024]; ERROR ("powerdns plugin: %s failed: %s", func, sstrerror (errno, errbuf, sizeof (errbuf))); } while (0)
+#define SOCK_ERROR(func, sockpath) do { char errbuf[1024]; ERROR ("powerdns plugin: Socket `%s` %s failed: %s", sockpath, func, sstrerror (errno, errbuf, sizeof (errbuf))); } while (0)
#define SERVER_SOCKET LOCALSTATEDIR"/run/pdns.controlsocket"
#define SERVER_COMMAND "SHOW * \n"
status = unlink (sa_unix.sun_path);
if ((status != 0) && (errno != ENOENT))
{
- FUNC_ERROR ("unlink");
+ SOCK_ERROR ("unlink", sa_unix.sun_path);
close (sd);
return (-1);
}
status = bind (sd, (struct sockaddr *) &sa_unix, sizeof (sa_unix));
if (status != 0)
{
- FUNC_ERROR ("bind");
+ SOCK_ERROR ("bind", sa_unix.sun_path);
break;
}
status = chmod (sa_unix.sun_path, 0666);
if (status != 0)
{
- FUNC_ERROR ("chmod");
+ SOCK_ERROR ("chmod", sa_unix.sun_path);
break;
}
status = setsockopt (sd, SOL_SOCKET, SO_RCVTIMEO, &stv_timeout, sizeof (stv_timeout));
if (status != 0)
{
- FUNC_ERROR ("setsockopt");
+ SOCK_ERROR ("setsockopt", sa_unix.sun_path);
break;
}
sizeof (item->sockaddr));
if (status != 0)
{
- FUNC_ERROR ("connect");
+ SOCK_ERROR ("connect", sa_unix.sun_path);
break;
}
status = send (sd, item->command, strlen (item->command), 0);
if (status < 0)
{
- FUNC_ERROR ("send");
+ SOCK_ERROR ("send", sa_unix.sun_path);
break;
}
status = recv (sd, temp, sizeof (temp), /* flags = */ 0);
if (status < 0)
{
- FUNC_ERROR ("recv");
+ SOCK_ERROR ("recv", sa_unix.sun_path);
break;
}
buffer_size = status + 1;
sizeof (item->sockaddr));
if (status != 0)
{
- FUNC_ERROR ("connect");
+ SOCK_ERROR ("connect", item->sockaddr.sun_path);
close (sd);
return (-1);
}
/* flags = */ 0);
if (status < 0)
{
- FUNC_ERROR ("send");
+ SOCK_ERROR ("send", item->sockaddr.sun_path);
close (sd);
return (-1);
}
status = recv (sd, temp, sizeof (temp), /* flags = */ 0);
if (status < 0)
{
- FUNC_ERROR ("recv");
+ SOCK_ERROR ("recv", item->sockaddr.sun_path);
break;
}
else if (status == 0)