From 29f18d8f865e1d18fe47ff3357c5bfbf81ff9c4d Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Mon, 16 Mar 2015 10:51:32 +0000 Subject: [PATCH] - Fixup compile on cygwin, more portable openssl thread id. git-svn-id: file:///svn/unbound/trunk@3362 be551aaa-1e26-0410-a405-d3ace91eadb9 --- doc/Changelog | 3 +++ util/log.c | 8 ++++++++ util/log.h | 9 +++++++++ util/net_help.c | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/Changelog b/doc/Changelog index 733affe92..14f0d9f40 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +16 March 2015: Wouter + - Fixup compile on cygwin, more portable openssl thread id. + 12 March 2015: Wouter - Updated default keylength in unbound-control-setup to 3k. diff --git a/util/log.c b/util/log.c index f90efa71c..3bf31ef3a 100644 --- a/util/log.c +++ b/util/log.c @@ -164,6 +164,14 @@ void log_thread_set(int* num) ub_thread_key_set(logkey, num); } +int log_thread_get(void) +{ + unsigned int* tid; + if(!key_created) return 0; + tid = (unsigned int*)ub_thread_key_get(logkey); + return (int)(tid?*tid:0); +} + void log_ident_set(const char* id) { ident = id; diff --git a/util/log.h b/util/log.h index ea283da7b..8e85ee620 100644 --- a/util/log.h +++ b/util/log.h @@ -97,6 +97,15 @@ void log_file(FILE *f); */ void log_thread_set(int* num); +/** + * Get the thread id from logging system. Set after log_init is + * initialised, or log_thread_set for newly created threads. + * This initialisation happens in unbound as a daemon, in daemon + * startup code, when that spawns threads. + * @return thread number, from 0 and up. Before initialised, returns 0. + */ +int log_thread_get(void); + /** * Set identity to print, default is 'unbound'. * @param id: string to print. Name of executable. diff --git a/util/net_help.c b/util/net_help.c index e2b7c3878..af70b1609 100644 --- a/util/net_help.c +++ b/util/net_help.c @@ -770,7 +770,7 @@ static lock_basic_t *ub_openssl_locks = NULL; static unsigned long ub_crypto_id_cb(void) { - return (unsigned long)ub_thread_self(); + return log_thread_get(); } static void -- 2.47.2