Mercurial > hg > freeDiameter
changeset 693:16c373df0947
Cleanups
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 21 Jan 2011 15:12:54 +0900 |
parents | dc1b3bd8ef54 |
children | 15f96c0a961d |
files | libfdcore/core.c libfdproto/init.c tests/tests.h |
diffstat | 3 files changed, 17 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libfdcore/core.c Fri Jan 21 11:23:39 2011 +0900 +++ b/libfdcore/core.c Fri Jan 21 15:12:54 2011 +0900 @@ -68,11 +68,11 @@ 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 @@ 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 */ );
--- a/libfdproto/init.c Fri Jan 21 11:23:39 2011 +0900 +++ b/libfdproto/init.c Fri Jan 21 15:12:54 2011 +0900 @@ -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;
--- a/tests/tests.h Fri Jan 21 11:23:39 2011 +0900 +++ b/tests/tests.h Fri Jan 21 15:12:54 2011 +0900 @@ -168,13 +168,13 @@ } } -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 @@ return; } -#define INIT_FD() test_init(argc, argv); +#define INIT_FD() test_init(argc, argv, __FILE__); #endif /* _TESTS_H */