File: 12-thread-debug.patch

package info (click to toggle)
linux-igd 1.0%2Bcvs20070630-5
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 888 kB
  • ctags: 618
  • sloc: ansic: 2,066; xml: 593; sh: 136; makefile: 50
file content (46 lines) | stat: -rw-r--r-- 1,199 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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);
 }