From e03f60f74126bdc791a517dd4be3784f7ba123c4 Mon Sep 17 00:00:00 2001 From: wrowe Date: Mon, 25 Nov 2002 05:06:31 +0000 Subject: As pointed out by Marcel Mann , we were returning 0xfffffffe (the pseudo-handle) for the current thread. Stash the real apr_thread_t and recover it for apr_os_thread_current(). We were also missing thread_compare so I dropped that in while I was at it. The test is simple with the above behavior. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64085 13f79535-47bb-0310-9956-ffa450edef68 --- threadproc/win32/thread.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'threadproc') diff --git a/threadproc/win32/thread.c b/threadproc/win32/thread.c index f602c96a3..12c6f2576 100644 --- a/threadproc/win32/thread.c +++ b/threadproc/win32/thread.c @@ -63,6 +63,9 @@ #endif #include "misc.h" +/* Chosen for us in apr_initialize */ +DWORD tls_apr_thread = 0; + APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, apr_pool_t *pool) { @@ -94,6 +97,7 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) static void *dummy_worker(void *opaque) { apr_thread_t *thd = (apr_thread_t *)opaque; + TlsSetValue(tls_apr_thread, thd); return thd->func(thd, thd->data); } @@ -214,7 +218,8 @@ APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void) { - return GetCurrentThread(); + apr_thread_t *thd = (apr_thread_t *)TlsGetValue(tls_apr_thread); + return thd->td; } APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, @@ -258,4 +263,14 @@ APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, return APR_SUCCESS; } +APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1, + apr_os_thread_t tid2) +{ + /* Since the only tid's we support our are own, and + * apr_os_thread_current returns the identical handle + * to the one we created initially, the test is simple. + */ + return (tid1 == tid2); +} + APR_POOL_IMPLEMENT_ACCESSOR(thread) -- cgit v1.2.1