tviced-log-thread-at-high-loglevel-20050224
authorDerrick Brashear <shadow@dementia.org>
Thu, 24 Feb 2005 15:21:28 +0000 (15:21 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 24 Feb 2005 15:21:28 +0000 (15:21 +0000)
if loglevel > 999, log thread id as part of logging

src/viced/viced.c

index e2251bc..3cbe1fb 100644 (file)
@@ -88,6 +88,7 @@ RCSID
 #include "host.h"
 #ifdef AFS_PTHREAD_ENV
 #include "softsig.h"
+char *(*threadNameProgram) ();
 #endif
 #if defined(AFS_SGI_ENV)
 #include "sys/schedctl.h"
@@ -315,6 +316,18 @@ ResetCheckDescriptors(void)
 #endif
 }
 
+#if defined(AFS_PTHREAD_ENV)
+char *
+threadName(void)
+{
+    char threadid[16];
+    if (LogLevel > 999) {
+       afs_snprintf(threadid, 16, "%d", pthread_getspecific(rx_thread_id_key));
+       return threadid;
+    } else 
+       return NULL;
+}
+#endif
 
 /* proc called by rxkad module to get a key */
 static int
@@ -1703,6 +1716,10 @@ main(int argc, char *argv[])
        V_BreakVolumeCallbacks = BreakVolumeCallBacksLater;
     }
 
+#if defined(AFS_PTHREAD_ENV)
+    threadNameProgram = threadName;
+#endif
+
     /* initialize libacl routines */
     acl_Initialize(ACL_VERSION);