Bug #3471 client/thread_test.c does not get compiled as a threaded program
Submitted: 14 Apr 2004 10:42 Modified: 28 Apr 2004 11:05
Reporter: Timothy Smith Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.19 OS:Unix
Assigned to: CPU Architecture:Any

[14 Apr 2004 10:42] Timothy Smith
Description:
The client/Makefile.am does attempt to compile thread_test as a threaded app, but doesn't do it correctly.

First, the DEFS = -DUNDEF_THREADS_HACK is still included in $(COMPILE), so not even THREAD is defined.

Next, if that is commented out, then the pthread library is not linked against.  E.g., on FreeBSD, I had to manually add the -pthread argument at the end of the libtool link command.

How to repeat:
compile with --enable-thread-safe-client, then ./client/thread_test

Suggested fix:
I don't know what's best.  The Makefile.am does:

LIBS = @CLIENT_LIBS@

so there's no way of getting a the standard LIBS (which is what contains the
threaded libs, e.g., '-pthread') inside of client/Makefile.

Probably it would work to add

THREADED_LIBS = @LIBS@

and then, somehow, remove $(DEFS) from $(COMPILE), and then specify to use $(THREADED_LIBS) when you link.

It's all ugly, though.
[28 Apr 2004 11:05] Michael Widenius
The thread test program is not meant as a working program but more an example of how you should code a thread program that uses MySQL.

There is no reason to fix this in 4.0.  We could look at fixing this in 4.1

I have changed this to a worklog entry instead of a bug.