summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/curl_threads.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libcurl/src/curl_threads.c')
-rw-r--r--libs/libcurl/src/curl_threads.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/libs/libcurl/src/curl_threads.c b/libs/libcurl/src/curl_threads.c
index 3879fb4355..c4831471d6 100644
--- a/libs/libcurl/src/curl_threads.c
+++ b/libs/libcurl/src/curl_threads.c
@@ -35,9 +35,7 @@
#endif
#include "curl_threads.h"
-#ifdef BUILDING_LIBCURL
#include "curl_memory.h"
-#endif
/* The last #include file should be: */
#include "memdebug.h"
@@ -82,11 +80,12 @@ err:
return curl_thread_t_null;
}
-void Curl_thread_destroy(curl_thread_t hnd)
+void Curl_thread_destroy(curl_thread_t *hnd)
{
- if(hnd != curl_thread_t_null) {
- pthread_detach(*hnd);
- free(hnd);
+ if(*hnd != curl_thread_t_null) {
+ pthread_detach(**hnd);
+ free(*hnd);
+ *hnd = curl_thread_t_null;
}
}
@@ -103,7 +102,7 @@ int Curl_thread_join(curl_thread_t *hnd)
#elif defined(USE_THREADS_WIN32)
curl_thread_t Curl_thread_create(
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
DWORD
#else
unsigned int
@@ -111,35 +110,39 @@ curl_thread_t Curl_thread_create(
(CURL_STDCALL *func) (void *),
void *arg)
{
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
typedef HANDLE curl_win_thread_handle_t;
#else
typedef uintptr_t curl_win_thread_handle_t;
#endif
curl_thread_t t;
curl_win_thread_handle_t thread_handle;
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
thread_handle = CreateThread(NULL, 0, func, arg, 0, NULL);
#else
thread_handle = _beginthreadex(NULL, 0, func, arg, 0, NULL);
#endif
t = (curl_thread_t)thread_handle;
if((t == 0) || (t == LongToHandle(-1L))) {
-#ifdef _WIN32_WCE
+#ifdef UNDER_CE
DWORD gle = GetLastError();
- errno = ((gle == ERROR_ACCESS_DENIED ||
- gle == ERROR_NOT_ENOUGH_MEMORY) ?
- EACCES : EINVAL);
+ /* !checksrc! disable ERRNOVAR 1 */
+ int err = (gle == ERROR_ACCESS_DENIED ||
+ gle == ERROR_NOT_ENOUGH_MEMORY) ?
+ EACCES : EINVAL;
+ CURL_SETERRNO(err);
#endif
return curl_thread_t_null;
}
return t;
}
-void Curl_thread_destroy(curl_thread_t hnd)
+void Curl_thread_destroy(curl_thread_t *hnd)
{
- if(hnd != curl_thread_t_null)
- CloseHandle(hnd);
+ if(*hnd != curl_thread_t_null) {
+ CloseHandle(*hnd);
+ *hnd = curl_thread_t_null;
+ }
}
int Curl_thread_join(curl_thread_t *hnd)
@@ -151,9 +154,7 @@ int Curl_thread_join(curl_thread_t *hnd)
int ret = (WaitForSingleObjectEx(*hnd, INFINITE, FALSE) == WAIT_OBJECT_0);
#endif
- Curl_thread_destroy(*hnd);
-
- *hnd = curl_thread_t_null;
+ Curl_thread_destroy(hnd);
return ret;
}