From a411086103f505b2ec2dc1089da57a522fe0714b Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 13 Nov 2003 03:35:57 +0000 Subject: [PATCH] ITS#2820 fix from HEAD - fix Draft 4 pthread_create, use pthread_equal --- libraries/libldap_r/thr_posix.c | 5 +++++ libraries/libldap_r/tpool.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/libraries/libldap_r/thr_posix.c b/libraries/libldap_r/thr_posix.c index 825761e330..ed0c9425b8 100644 --- a/libraries/libldap_r/thr_posix.c +++ b/libraries/libldap_r/thr_posix.c @@ -121,7 +121,12 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread, pthread_attr_setdetachstate(&attr, detach); #endif #endif + +#if HAVE_PTHREADS < 5 + rtn = pthread_create( thread, attr, start_routine, arg ); +#else rtn = pthread_create( thread, &attr, start_routine, arg ); +#endif #if HAVE_PTHREADS > 5 pthread_attr_destroy(&attr); #else diff --git a/libraries/libldap_r/tpool.c b/libraries/libldap_r/tpool.c index f9ecded4d5..002f9a5cf7 100644 --- a/libraries/libldap_r/tpool.c +++ b/libraries/libldap_r/tpool.c @@ -42,6 +42,12 @@ typedef struct ldap_int_thread_key_s { */ #define MAXKEYS 32 +#ifdef HAVE_PTHREADS +#define TID_EQ(a,b) pthread_equal((a),(b)) +#else +#define TID_EQ(a,b) ((a) == (b)) +#endif + typedef struct ldap_int_thread_ctx_s { union { LDAP_STAILQ_ENTRY(ldap_int_thread_ctx_s) q; @@ -521,8 +527,8 @@ void *ldap_pvt_thread_pool_context( ldap_pvt_thread_pool_t *tpool ) ldap_pvt_thread_mutex_lock(&pool->ltp_mutex); LDAP_SLIST_FOREACH(ptr, &pool->ltp_active_list, ltc_next.al) - if (ptr != NULL && ptr->ltc_thread_id == tid) break; - if (ptr != NULL && ptr->ltc_thread_id != tid) { + if (ptr != NULL && TID_EQ(ptr->ltc_thread_id, tid)) break; + if (ptr != NULL && !TID_EQ(ptr->ltc_thread_id, tid)) { ptr = NULL; } ldap_pvt_thread_mutex_unlock(&pool->ltp_mutex); -- 2.47.2