]> code.citadel.org Git - citadel.git/blobdiff - citadel/threads.c
* by counting up threads starting at 3, we seem to get what top shows in the LWPID...
[citadel.git] / citadel / threads.c
index a678d60a37cfb5be42e2af6e561b78d2262dd8e9..f6221019a9e95377935d181d87defa955ad85150 100644 (file)
@@ -58,6 +58,7 @@
  * remove the need for the calls to eCrashRegisterThread and friends
  */
 
+static int next_tid = 3;                        /* offset LWPID to PID */
 static int num_threads = 0;                    /* Current number of threads */
 static int num_workers = 0;                    /* Current number of worker threads */
 long statcount = 0;            /* are we doing a stats check? */
@@ -594,10 +595,20 @@ static void ctdl_internal_thread_cleanup(void *arg)
         * In here we were called by the current thread because it is exiting
         * NB. WE ARE THE CURRENT THREAD
         */
-       CtdlLogPrintf(CTDL_NOTICE, "Thread \"%s\" (0x%08lx) exited.\n", CT->name, CT->tid);
+       if (CT)
+       {
+               const char *name = CT->name;
+               const pid_t tid = CT->tid;
+
+               CtdlLogPrintf(CTDL_NOTICE, "Thread \"%s\" (0x%08lx) exited.\n", name, tid);
+       }
+       else 
+       {
+               CtdlLogPrintf(CTDL_NOTICE, "some ((unknown ? ? ?) Thread exited.\n");
+       }
        
        #ifdef HAVE_BACKTRACE
-       eCrash_UnregisterThread();
+///    eCrash_UnregisterThread();
        #endif
        
        citthread_mutex_lock(&CT->ThreadMutex);
@@ -825,7 +836,7 @@ static void *ctdl_internal_thread_func (void *arg)
        
        // Register for tracing
        #ifdef HAVE_BACKTRACE
-       eCrash_RegisterThread(this_thread->name, 0);
+///    eCrash_RegisterThread(this_thread->name, 0);
        #endif
        
        // Tell the world we are here
@@ -979,7 +990,8 @@ CtdlThreadNode *ctdl_internal_create_thread(char *name, long flags, void *(*thre
                free(this_thread);
                return NULL;
        }
-       
+       this_thread->reltid = next_tid;
+       next_tid++;
        num_threads++;  // Increase the count of threads in the system.
        if(this_thread->flags & CTDLTHREAD_WORKER)
                num_workers++;