summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan@13f79535-47bb-0310-9956-ffa450edef68>2022-06-27 12:12:16 +0000
committerivan <ivan@13f79535-47bb-0310-9956-ffa450edef68>2022-06-27 12:12:16 +0000
commitbf1548fa54dd86d31d6225658b4e0838f565f8e5 (patch)
treec688c5e128d508d109124f2275333baea708fd0e
parent63a137e5c3f29af217bc3daaf524a5f7e7546d44 (diff)
downloadlibapr-bf1548fa54dd86d31d6225658b4e0838f565f8e5.tar.gz
win32: Fix potential race condition in apr_thread_create.
* CHANGES: Add changelog entry. * threadproc/win32/thread.c (apr_thread_create): Create suspended thread, initialize apr_thread_t->td and only after that resume thread. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902277 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES2
-rw-r--r--threadproc/win32/thread.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 332d60327..4b5d3456f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -266,6 +266,8 @@ Changes for APR 2.0.0
*) Fix double free on exit when apr_app is used on Windows. [Ivan Zhakov]
+ *) apr_thread_create: Fix potential race condition on Windows. [Ivan Zhakov]
+
Changes for APR and APR-util 1.7.x and later:
*) http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/CHANGES?view=markup
diff --git a/threadproc/win32/thread.c b/threadproc/win32/thread.c
index c49038361..0b672e698 100644
--- a/threadproc/win32/thread.c
+++ b/threadproc/win32/thread.c
@@ -157,17 +157,19 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
if ((handle = (HANDLE)_beginthreadex(NULL,
(DWORD) (attr ? attr->stacksize : 0),
dummy_worker,
- (*new), 0, &temp)) == 0) {
+ (*new), CREATE_SUSPENDED, &temp)) == 0) {
stat = APR_FROM_OS_ERROR(_doserrno);
apr_pool_destroy((*new)->pool);
return stat;
}
if (attr && attr->detach) {
+ ResumeThread(handle);
CloseHandle(handle);
}
else {
(*new)->td = handle;
+ ResumeThread(handle);
}
return APR_SUCCESS;