cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [ curl-Bugs-927979 ] win32 thread usage

From: Gisle Vanem <gvanem_at_broadpark.no>
Date: Fri, 2 Apr 2004 16:19:55 +0200

"Nathan O'Sullivan" <nathan_at_mammoth.com.au> said:

> So it depends how you link the run-time in. However, there's no negative
> (that I'm aware of) to calling _beginthreadex()

Probably why I didn't notice any leak (I always link to msvcrt.dll)

> Re CloseHandle()
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__beginthread.2c_._beginthreadex.asp
>
> "endthread automatically closes the thread handle (whereas _endthreadex does
> not). Therefore, when using _beginthread and _endthread, do not explicitly
> close the thread handle by calling the Win32 CloseHandle API." -- Which
> kind of covers the inverse.

_endthreadex() is rather confusing. It cannot AFAICS be called from
the parent-thread since it doesn't take a thread-handle (as TerminateThread
does).

Hopefully the attached patch fixes the leak.

BTW. Anybody know how MingW can use the debug version of the runtime;
msvcrtd.dll? I tried to link with that, but curl crashed. I suppose MingW cannot
produce the nice leak reports that MSVC can in debug-mode.

The hostip.c is becoming unmanageable with all the ifdef combinations.
Maybe we should split it up into hostip4.c and hostip6.c with the common
details in hostip.h (inside a #ifdef HOSTIP_IMPLEMENTATION).

--gv

Received on 2004-04-02