Replaced logging queries with sending on socket.

Change-Id: Ifeb9ddc9db1055e2b71e9f7dcbdc8e2f0417669e
diff --git a/src/forward.c b/src/forward.c
index e7e0d33..e19b513 100644
--- a/src/forward.c
+++ b/src/forward.c
@@ -15,6 +15,7 @@
 */
 
 #include "dnsmasq.h"
+#include <sys/socket.h>
 
 static struct frec *lookup_frec(unsigned short id, void *hash);
 static struct frec *lookup_frec_by_sender(unsigned short id,
@@ -1309,19 +1310,24 @@
 #endif
 	  if (strcmp("127.0.0.1", daemon->addrbuff) != 0)
 		{
-		  FILE *fp;
-		  fp = fopen("/tmp/dns_query_log.txt", "a");
-		  if (fp == NULL)
+		  int sock;
+		  if ((sock = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0)
 			{
-			  my_syslog(LOG_ERR, "failed to open /tmp/dns_query_log.txt: %s", strerror(errno));
+			  my_syslog(LOG_ERR, "failed to create socket: %s", strerror(errno));
 			}
-		  else
+		  struct sockaddr_un server_address = {AF_UNIX, "/tmp/dns_query_log_socket"};
+		  char msg[128];
+		  sprintf(msg, "%lu %s", now, daemon->namebuff);
+		  if (sendto(sock, msg, strlen(msg), 0, (struct sockaddr *)&server_address,
+		  			sizeof(server_address)) < 0)
 			{
-			  fprintf(fp, "%lu %s\n", now, daemon->namebuff);
-			  fclose(fp);
+			  my_syslog(LOG_ERR, "failed to send message on socket: %s", strerror(errno));
+			}
+		  if (close(sock) < 0)
+			{
+			  my_syslog(LOG_ERR, "failed to close socket: %s", strerror(errno));
 			}
 		}
-
 #ifdef HAVE_AUTH
       /* find queries for zones we're authoritative for, and answer them directly */
       if (!auth_dns)