Bug #8472 Solaris 9 client cannot connect to server in threaded environment
Submitted: 12 Feb 2005 12:07 Modified: 7 May 2005 9:24
Reporter: Paul Kranenburg Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.2 alpha OS:Solaris (Solaris 9)
Assigned to: CPU Architecture:Any

[12 Feb 2005 12:07] Paul Kranenburg
Description:
When building the shared client library from source on Solaris 9 `UNDEF_THREADS_HACK' gets defined. In turn, this leads to the inclusion of
the system header file <errno.h> without defining _REENTRANT. As a result,
`errno' is declared as a global integer.

This is incorrect in a threaded environment and leads to incorrect behaviour of
the function my_connect(). This function examines the `errno value' corresponding
to the main thread instead of the per-thread  value and returns failure.

Most likely, lots of other functions are affected as well, if only by reporting
incorrect error messages on failure.

How to repeat:
Use the client code to connect to a mysql server from a thread-enabled web server
such as apache 2.0.x

Suggested fix:
I'm not sure what UNDEF_THREADS_HACK is all about.
But at least on Solaris always make sure _REENTRANT is defined.
[7 May 2005 9:24] Hartmut Holzgraefe
We provide two different library versions: libmysqlclient and libmysqlclient_r.
Only the later one is thread safe itself so this is the library you want to link
multi threaded application against.
You have to configure the source with --enable-thread-safe-client to build it.