You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by wr...@apache.org on 2002/11/25 06:06:31 UTC
cvs commit: apr/misc/win32 start.c
wrowe 2002/11/24 21:06:31
Modified: threadproc/win32 thread.c
misc/win32 start.c
Log:
As pointed out by Marcel Mann <Ma...@dbaudio.com>, 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.
Revision Changes Path
1.49 +16 -1 apr/threadproc/win32/thread.c
Index: thread.c
===================================================================
RCS file: /home/cvs/apr/threadproc/win32/thread.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- thread.c 22 Aug 2002 23:29:01 -0000 1.48
+++ thread.c 25 Nov 2002 05:06:31 -0000 1.49
@@ -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 @@
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_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,
@@ -256,6 +261,16 @@
func();
}
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)
1.42 +6 -0 apr/misc/win32/start.c
Index: start.c
===================================================================
RCS file: /home/cvs/apr/misc/win32/start.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- start.c 15 Sep 2002 21:35:22 -0000 1.41
+++ start.c 25 Nov 2002 05:06:31 -0000 1.42
@@ -195,6 +195,9 @@
static int initialized = 0;
+/* Provide to win32/thread.c */
+extern DWORD tls_apr_thread;
+
APR_DECLARE(apr_status_t) apr_initialize(void)
{
apr_pool_t *pool;
@@ -213,6 +216,7 @@
return APR_EEXIST;
}
+ tls_apr_thread = TlsAlloc();
if ((status = apr_pool_initialize()) != APR_SUCCESS)
return status;
@@ -247,6 +251,8 @@
apr_pool_terminate();
WSACleanup();
+
+ TlsFree(tls_apr_thread);
}
APR_DECLARE(void) apr_terminate2(void)