This is the mail archive of the pthreads-win32@sources.redhat.com mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

GetLastError trampled on by pthread_self


I've found that calling pthread_self() results in the value returned by
GetLastError() and WSAGetLastError() being reset.

pthread_self() calls pthread_getspecific() which calls TlsGetValue().  The
Win32 documentation for TlsGetValue() states:

	"Win32 functions that return indications of failure call SetLastError when
they fail. They generally do not call SetLastError when they succeed. The
TlsGetValue function is an exception to this general rule. The TlsGetValue
function calls SetLastError to clear a thread's last error when it
succeeds." ...

I have fixed this by doing a GetLastError() and SetLastError() around the
TlsGetValue() call to save and restore the last error.  This fixes my
specific problem, I'm just wondering whether you guys want to implement it
in the pthreads-win32 library, or whether you consider it for the caller of
the library to do around the pthread_self() call.

Regards,

Steven

--
Essemer - Software & Hardware Development
http://www.essemer.com.au/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]