From af0216251b94e751baa47146ac9609db70793b8e Mon Sep 17 00:00:00 2001 From: Jay Satiro Date: Mon, 19 Jun 2017 00:52:38 -0400 Subject: curl_setup_once: Remove ERRNO/SET_ERRNO macros Prior to this change (SET_)ERRNO mapped to GetLastError/SetLastError for Win32 and regular errno otherwise. I reviewed the code and found no justifiable reason for conflating errno on WIN32 with GetLastError/SetLastError. All Win32 CRTs support errno, and any Win32 multithreaded CRT supports thread-local errno. Fixes https://github.com/curl/curl/issues/895 Closes https://github.com/curl/curl/pull/1589 --- lib/curl_threads.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'lib/curl_threads.c') diff --git a/lib/curl_threads.c b/lib/curl_threads.c index a78eff5c2..19897107a 100644 --- a/lib/curl_threads.c +++ b/lib/curl_threads.c @@ -104,15 +104,22 @@ int Curl_thread_join(curl_thread_t *hnd) curl_thread_t Curl_thread_create(unsigned int (CURL_STDCALL *func) (void *), void *arg) { + curl_thread_t t; #ifdef _WIN32_WCE - return CreateThread(NULL, 0, func, arg, 0, NULL); + t = CreateThread(NULL, 0, func, arg, 0, NULL); #else - curl_thread_t t; t = (curl_thread_t)_beginthreadex(NULL, 0, func, arg, 0, NULL); - if((t == 0) || (t == (curl_thread_t)-1L)) +#endif + if((t == 0) || (t == (curl_thread_t)-1L)) { +#ifdef _WIN32_WCE + DWORD gle = GetLastError(); + errno = ((gle == ERROR_ACCESS_DENIED || + gle == ERROR_NOT_ENOUGH_MEMORY) ? + EACCES : EINVAL); +#endif return curl_thread_t_null; + } return t; -#endif } void Curl_thread_destroy(curl_thread_t hnd) -- cgit v1.2.3