aboutsummaryrefslogtreecommitdiff
path: root/dnstap/dnstap.c
diff options
context:
space:
mode:
Diffstat (limited to 'dnstap/dnstap.c')
-rw-r--r--dnstap/dnstap.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/dnstap/dnstap.c b/dnstap/dnstap.c
index 5d0420f6fbba..aabf8eec9071 100644
--- a/dnstap/dnstap.c
+++ b/dnstap/dnstap.c
@@ -39,6 +39,10 @@
#include "config.h"
#include <string.h>
#include <sys/time.h>
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#include <errno.h>
#include "sldns/sbuffer.h"
#include "util/config_file.h"
#include "util/net_help.h"
@@ -118,6 +122,18 @@ dt_msg_init(const struct dt_env *env,
}
}
+/* check that the socket file can be opened and exists, print error if not */
+static void
+check_socket_file(const char* socket_path)
+{
+ struct stat statbuf;
+ memset(&statbuf, 0, sizeof(statbuf));
+ if(stat(socket_path, &statbuf) < 0) {
+ log_warn("could not open dnstap-socket-path: %s, %s",
+ socket_path, strerror(errno));
+ }
+}
+
struct dt_env *
dt_create(const char *socket_path, unsigned num_workers)
{
@@ -134,6 +150,7 @@ dt_create(const char *socket_path, unsigned num_workers)
socket_path);
log_assert(socket_path != NULL);
log_assert(num_workers > 0);
+ check_socket_file(socket_path);
env = (struct dt_env *) calloc(1, sizeof(struct dt_env));
if (!env)