Description: Add thread ID to debug messages to aid debugging
Author: Nick Leverton <nick@leverton.org>

Index: linux-igd-1.0+cvs20070630-libupnp6/util.c
===================================================================
--- linux-igd-1.0+cvs20070630-libupnp6.orig/util.c	2014-10-07 23:35:40.000000000 +0100
+++ linux-igd-1.0+cvs20070630-libupnp6/util.c	2014-10-07 23:35:52.000000000 +0100
@@ -1,6 +1,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdlib.h>
 #include <syslog.h>
 #include <arpa/inet.h>
 #include <linux/sockios.h>
@@ -10,6 +11,7 @@
 #include <sys/socket.h>
 #include "globals.h"
 
+#include <ithread.h>
 
 static int get_sockfd(void)
 {
@@ -56,9 +58,19 @@
 void trace(int debuglevel, const char *format, ...)
 {
   va_list ap;
-  va_start(ap,format);
-  if (g_vars.debug>=debuglevel) {
-    vsyslog(LOG_DEBUG,format,ap);
+  char *thr_format;
+
+  va_start(ap, format);
+
+  if( -1 == asprintf(&thr_format, "0x%lx %s", (unsigned long int)ithread_self(), format) )
+    thr_format = format;
+
+  if (g_vars.debug >= debuglevel) {
+    vsyslog(LOG_DEBUG, thr_format,  ap);
   }
+
+  if( thr_format != format )
+    free(thr_format);
+
   va_end(ap);
 }
