return NULL;
}
begin_critical_section(S_THREAD_LIST);
+ old_name = this_thread->name;
if (name)
- {
- old_name = this_thread->name;
this_thread->name = strdup (name);
- free(old_name);
- }
- old_name = strdup(this_thread->name);
+ else
+ old_name = strdup(old_name);
end_critical_section (S_THREAD_LIST);
return (old_name);
}
worker_avg += that_thread->load_avg;
workers++;
}
+#ifdef WITH_THREADLOG
CtdlLogPrintf(CTDL_DEBUG, "CtdlThread, \"%s\" (%ld) \"%s\" %f %f %f %f.\n",
that_thread->name,
that_thread->tid,
that_thread->avg_running,
that_thread->avg_blocked,
that_thread->load_avg);
-
+#endif
pthread_mutex_unlock(&that_thread->ThreadMutex);
that_thread = that_thread->next;
}
CtdlThreadLoadAvg = load_avg/num_threads;
CtdlThreadWorkerAvg = worker_avg/workers;
+#ifdef WITH_THREADLOG
CtdlLogPrintf(CTDL_INFO, "System load average %f, workers averag %f\n", CtdlThreadLoadAvg, CtdlThreadWorkerAvg);
+#endif
end_critical_section(S_THREAD_LIST);
}
if(num_threads == 1)
CtdlThreadList->state = CTDL_THREAD_EXITED;
+#ifdef WITH_THREADLOG
CtdlLogPrintf(CTDL_DEBUG, "Thread system running garbage collection.\n");
+#endif
/*
* Woke up to do garbage collection
*/
void dead_session_purge(int force) {
struct CitContext *ptr, *ptr2; /* general-purpose utility pointer */
struct CitContext *rem = NULL; /* list of sessions to be destroyed */
-
+
+ CtdlThreadPushName("dead_session_purge");
+
if (force == 0) {
if ( (time(NULL) - last_purge) < 5 ) {
+ CtdlThreadPopName();
return; /* Too soon, go away */
}
}
}
end_critical_section(S_THREAD_LIST);
// FIXME: reduce the number of worker threads too
+
+ CtdlThreadPopName();
+
}