Re: libct ct_connect thread_safe

Peter Deacon <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <alpine.WNT.2.00.1112152040140.2472@SMURF>
On Thu, 15 Dec 2011, James K. Lowden wrote:

> On Thu, 15 Dec 2011 11:06:39 -0500
> [email protected] (Christos Zoulas) wrote:

>> | I have 2 threads each with their *own* connection to different
>> | servers. The problem is
>> |
>> | static SSL_CTX *ssl_ctx
>> |
>> | inside net.c and the way it is being initialized.

>> This is easily fixed as follows... I added some othe minor fixes as a
>> christmas bonus.

> Thanks, Christos.  Applied to CVS HEAD.  Merry Christmas to you, too.

> IIUC the use-case here is two threads each opening its own connection.
> That should work, yes.

Reminds me OpenSSL is a bit weird in that you have to register your own 
synchronization callbacks (reader/writers) in order for SSL to be 
thread safe.

Even if you keep connections in their separate threads there is still a 
little bit of shared state to manage the caches for SSL session resumption 
in the client.  Given TDS connections tend to be relatively long lived it 
is very hard to get this sort of synchronization bugs to materialize in 
real life.  It can creep up if your app is making lots of new connections 
concurrently.

Does anyone have a problem with assuming pthread_rewlock_* is available 
on UNIX systems where TDS_HAVE_PTHREAD_MUTEX is defined?

regards,
Peter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.