Commit 8dbdace1 authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

Cleanups

parent 37a1e947
......@@ -68,11 +68,11 @@ enum core_mode {
static void * core_runner_thread(void * arg)
{
fd_log_threadname("Core Runner");
if (arg && (*(int *)arg == CORE_MODE_IMMEDIATE))
goto end;
fd_log_threadname("fD Core Runner");
/* Handle events incoming on the main event queue */
while (1) {
int code; size_t sz; void * data;
......@@ -130,6 +130,7 @@ static void * core_runner_thread(void * arg)
end:
TRACE_DEBUG(INFO, FD_PROJECT_BINARY " framework is stopping...");
fd_log_threadname("fD Core Shutdown");
/* cleanups */
CHECK_FCT_DO( fd_servers_stop(), /* Stop accepting new connections */ );
......
......@@ -38,13 +38,23 @@
/* Only for CPU cache flush */
pthread_mutex_t fd_cpu_mtx_dummy = PTHREAD_MUTEX_INITIALIZER;
/* function to free the threadnames */
static void freelogstr(void * str) {
if (TRACE_BOOL(ANNOYING)) {
if (str) {
fd_log_debug("(Thread '%s' terminating)\n", (char *)str);
}
}
free(str);
}
/* Initialize library variables and threads */
int fd_libproto_init()
{
int ret = 0;
/* Create the thread key that contains thread name for debug messages */
ret = pthread_key_create(&fd_log_thname, free);
ret = pthread_key_create(&fd_log_thname, freelogstr);
if (ret != 0) {
fprintf(stderr, "Error initializing the libfreeDiameter library: %s\n", strerror(ret) );
return ret;
......
......@@ -168,13 +168,13 @@ static inline void parse_cmdline(int argc, char * argv[]) {
}
}
static inline void test_init(int argc, char * argv[])
static inline void test_init(int argc, char * argv[], char *fname)
{
memset(fd_g_config, 0, sizeof(struct fd_config));
CHECK( 0, fd_libproto_init() );
fd_log_threadname(basename(__FILE__));
fd_log_threadname(basename(fname));
/* Initialize gcrypt and gnutls */
(void) gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
......@@ -198,6 +198,6 @@ static inline void test_init(int argc, char * argv[])
return;
}
#define INIT_FD() test_init(argc, argv);
#define INIT_FD() test_init(argc, argv, __FILE__);
#endif /* _TESTS_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment