From a2f1c95d402bf524b9df76bdc85643dfb940894f Mon Sep 17 00:00:00 2001
From: Kurt Zeilenga <kurt@openldap.org>
Date: Sun, 6 May 2001 21:52:58 +0000
Subject: [PATCH] Import thread fix

---
 libraries/libldap_r/thr_nt.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libraries/libldap_r/thr_nt.c b/libraries/libldap_r/thr_nt.c
index 620da6b642..0f774e5629 100644
--- a/libraries/libldap_r/thr_nt.c
+++ b/libraries/libldap_r/thr_nt.c
@@ -35,9 +35,16 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
 	void *(*start_routine)( void *),
 	void *arg)
 {
-	*thread = (ldap_pvt_thread_t)_beginthread( (void *) start_routine, 
-						0, arg );
-	 return ( (unsigned long)*thread == -1 ? -1 : 0 );
+	unsigned long tid
+	HANDLE thd;
+
+	thd = _beginthreadex( NULL, 0,
+		(LPTHREAD_START_ROUTINE) start_routine, arg,
+		0, &tid );
+
+	*thread = (ldap_pvt_thread_t) thd;
+
+	 return thd == NULL ? -1 : 0;
 }
 	
 void 
-- 
GitLab