diff options
author | Stef Walter <stefw@gnome.org> | 2012-07-17 08:06:28 +0200 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2012-07-26 12:22:31 +0200 |
commit | 06595e93ff57e97adbb313aebc50a2e32acd6039 (patch) | |
tree | 01b3af353a23c55b0f7f8947e17145b0a72996af /p11-kit | |
parent | 356377709cd1de1308d9d8cf15f528578a360cf3 (diff) |
Use Windows thread ids instead of handles for comparisons
* It seems that the HANDLE's returned from GetCurrentThread
are often equal for two threads. GetCurrentThreadID doesn't
have this problem.
* Separate our cross platform thread_t and thread_id_t types
even though on unix they're the same thing.
https://bugzilla.gnome.org/show_bug.cgi?id=44740
Diffstat (limited to 'p11-kit')
-rw-r--r-- | p11-kit/modules.c | 6 | ||||
-rw-r--r-- | p11-kit/util.h | 11 |
2 files changed, 11 insertions, 6 deletions
diff --git a/p11-kit/modules.c b/p11-kit/modules.c index f965b5c..547ee02 100644 --- a/p11-kit/modules.c +++ b/p11-kit/modules.c @@ -109,7 +109,7 @@ typedef struct _Module { /* Initialization, mutex must be held */ mutex_t initialize_mutex; int initialize_called; - thread_t initialize_thread; + thread_id_t initialize_thread; } Module; /* @@ -531,10 +531,10 @@ static CK_RV initialize_module_unlocked_reentrant (Module *mod) { CK_RV rv = CKR_OK; - thread_t self; + thread_id_t self; assert (mod); - self = _p11_thread_self (); + self = _p11_thread_id_self (); if (mod->initialize_thread == self) { _p11_message ("p11-kit initialization called recursively"); diff --git a/p11-kit/util.h b/p11-kit/util.h index 2da4db6..b8d4a15 100644 --- a/p11-kit/util.h +++ b/p11-kit/util.h @@ -65,6 +65,8 @@ typedef CRITICAL_SECTION mutex_t; typedef HANDLE thread_t; +typedef DWORD thread_id_t; + #define _p11_mutex_init(m) \ (InitializeCriticalSection (m)) #define _p11_mutex_lock(m) \ @@ -80,8 +82,9 @@ int _p11_thread_create (thread_t *thread, thread_routine, void *arg); int _p11_thread_join (thread_t thread); -#define _p11_thread_self() \ - (GetCurrentThread ()) +/* Returns a thread_id_t */ +#define _p11_thread_id_self() \ + (GetCurrentThreadId ()) typedef HMODULE dl_module_t; @@ -122,13 +125,15 @@ void _p11_mutex_init (mutex_t *mutex); typedef pthread_t thread_t; +typedef pthread_t thread_id_t; + typedef void * (*thread_routine) (void *arg); #define _p11_thread_create(t, r, a) \ (pthread_create ((t), NULL, (r), (a))) #define _p11_thread_join(t) \ (pthread_join ((t), NULL)) -#define _p11_thread_self(m) \ +#define _p11_thread_id_self(m) \ (pthread_self ()) typedef void * dl_module_t; |