--- deadwood-2.9.03/src/DwSocket.c.orig	2010-08-06 05:50:57.000000000 -0700
+++ deadwood-2.9.03/src/DwSocket.c	2010-08-06 06:05:48.000000000 -0700
@@ -826,6 +826,8 @@
                    dw_put_u16(packet,1,-1) == -1 /* QCLASS: 1 */) {
                         goto catch_handle_expired;
                 }
+		dw_log_dwstr_str("Connection for query ",rem[a].query,
+				" did not respond; trying again",128);
                 make_remote_connection(a,(unsigned char *)packet->str,
                                 packet->len,rem[a].query,INVALID_SOCKET);
                 rem[a].die = get_time() + ((int64_t)timeout_seconds << 8);
--- deadwood-2.9.03/src/DwUdpSocket.c.orig	2010-08-06 06:06:03.000000000 -0700
+++ deadwood-2.9.03/src/DwUdpSocket.c	2010-08-06 06:07:02.000000000 -0700
@@ -197,6 +197,7 @@
 
         /* Get IP of remote server and open a socket to them */
         addr = get_upstream_ip(query,n);
+	dw_log_ip("Making connection to IP",&addr,128);
         if(addr.len == 0) { /* Failed to get upstream IP */
                 return;
         } else if(addr.len == 4 || addr.len == 16) { /* IPv4/IPv6 IP */
--- deadwood-2.9.03/src/DwSocket.h.orig	2010-07-29 10:39:10.000000000 -0700
+++ deadwood-2.9.03/src/DwSocket.h	2010-08-06 06:23:14.000000000 -0700
@@ -39,7 +39,6 @@
 
 #include "DwStr.h"
 #include "DwMararc.h"
-#include "DwSys.h"
 #include "DwStr_functions.h"
 #include "DwRadioGatun.h"
 #include "DwHash.h"
@@ -99,6 +98,8 @@
         uint8_t flags;
 } ip_addr_T;
 
+#include "DwSys.h" /* DwSys.h needs ip_addr_t */
+
 /* Structure for storing an IP address *and* a netmask; note that the
  * beginning of the structure *must* have the exact same form as the
  * ip_addr_T structure above */
--- deadwood-2.9.03/src/DwSocket.h.orig	2010-08-06 06:38:16.000000000 -0700
+++ deadwood-2.9.03/src/DwSocket.h	2010-08-06 06:38:50.000000000 -0700
@@ -54,7 +54,9 @@
 #include <grp.h>
 #else  /* MINGW */
 /* Maximum number of open sockets; make this big like it is in *NIX */
+#ifndef FD_SETSIZE
 #define FD_SETSIZE 512
+#endif /* FD_SETSIZE */
 #include <winsock.h>
 #include <wininet.h>
 #endif /* MINGW */
--- deadwood-2.9.03/src/DwSys.h.orig	2010-08-06 06:40:52.000000000 -0700
+++ deadwood-2.9.03/src/DwSys.h	2010-08-06 06:41:24.000000000 -0700
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2009 Sam Trenholme
+/* Copyright (c) 2007-2010 Sam Trenholme
  *
  * TERMS
  *
@@ -16,14 +16,18 @@
  * fitness for purpose.
  */
 
+#ifndef __DWSYS_H_DEFINED__
+#define __DWSYS_H_DEFINED__
+
+#ifndef MINGW
+#include <grp.h>
+#endif /* MINGW */
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <time.h>
-#ifndef MINGW
-#include <grp.h>
-#endif /* MINGW */
+#include "DwSocket.h"
 
 /* Parameters that are currently hardcoded in the source code (This will
  * change once we get something very basic that works) */
@@ -47,6 +51,9 @@
 /* Close the log */
 void dw_log_close();
 
+/* Log a char followed by an IP */
+void dw_log_ip(char *string, ip_addr_T *ip, int min_log_level);
+
 /* Log a string followed by the contents of a DwStr object */
 void dw_log_dwstr(char *s1, dw_str *s2, int min_log_level);
 
@@ -139,3 +146,5 @@
  * the def value */
 int32_t get_key_n(int32_t get, int32_t min, int32_t max, int32_t def);
 
+#endif /* __DWSYS_H_DEFINED__ */
+
--- deadwood-2.9.03/src/DwSys.c.orig	2010-08-06 08:02:05.000000000 -0700
+++ deadwood-2.9.03/src/DwSys.c	2010-08-06 08:03:09.000000000 -0700
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2009 Sam Trenholme
+/* Copyright (c) 2007-2010 Sam Trenholme
  *
  * TERMS
  *
@@ -126,6 +126,80 @@
         }
 }
 
+/* Log an IP; private */
+void dw_log_ip_p(ip_addr_T *ip) {
+	int counter = 0;
+
+	if(ip == 0) {
+#ifndef MINGW
+		printf("%s","(null IP)\n");
+#else /* MINGW */
+		fprintf(LOG,"%s","(null IP)\n");
+#endif /* MINGW */
+		return;
+	}
+
+	if(ip->len == 4) {
+		for(counter = 0; counter < 3; counter++) {
+#ifndef MINGW
+			printf("%d.",ip->ip[counter]);
+#else /* MINGW */
+			fprintf(LOG,"%d.",ip->ip[counter]);
+#endif /* MINGW */
+		}
+#ifndef MINGW
+		printf("%d ",ip->ip[3]);
+#else /* MINGW */
+		fprintf(LOG,"%d ",ip->ip[3]);
+#endif /* MINGW */
+#ifdef IPV6
+	} else if(ip->len == 16) {
+		for(counter = 0; counter < 15; counter++) {
+#ifndef MINGW
+			printf("%02x:",ip->ip[counter]);
+#else /* MINGW */
+			fprintf(LOG,"%02x:",ip->ip[counter]);
+#endif /* MINGW */
+		}
+#ifndef MINGW
+		printf("%02x ",ip->ip[15]);
+#else /* MINGW */
+		fprintf(LOG,"%02x ",ip->ip[15]);
+#endif /* MINGW */
+#endif /* IPV6 */
+	} else {
+#ifndef MINGW
+		printf("%s%d","IP of length ",ip->len);
+#else /* MINGW */
+		fprintf(LOG,"%s%d","IP of length ",ip->len);
+#endif /* MINGW */
+	}
+}		
+
+/* Log a char followed by an IP */
+void dw_log_ip(char *string, ip_addr_T *ip, int min_log_level) {
+        int32_t ll = key_n[DWM_N_verbose_level];
+        if(ll <= 0 || ll < min_log_level) {
+                return;
+        }
+
+#ifndef MINGW
+        printf("%s ",string);
+#else /* MINGW */
+        dw_win_time();
+        fprintf(LOG,"%s ",string);
+#endif /* MINGW */
+
+	dw_log_ip_p(ip);
+
+#ifndef MINGW
+        printf("%s","\n");
+#else /* MINGW */
+        fprintf(LOG,"%s","\n");
+#endif /* MINGW */
+	
+}
+
 /* Log a string followed by the contents of a DwStr object */
 void dw_log_dwstr(char *s1, dw_str *s2, int min_log_level) {
         int32_t ll = key_n[DWM_N_verbose_level];
