cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: AIX multithreaded problem in CURLE_SSL_CONNECT_ERROR,why?

From: hzhijun <hzhijun_at_huawei.com>
Date: Fri, 19 Nov 2004 14:48:13 +0800

Hi, Frank
   I really a newbie to the OpenSSL callback usage. If I set the locak callback,
What should be done in the callback function?
  Thanks

> hzhijun wrote:
> > i don't think it need to set locking_function since i did not use any shared datastructures in my application.
> you may not, but the OpenSSL-LIB does definitly. And as soon as your
> application gets multithreaded, you always risk a race conditions which
> not neccessarily could cause a crash, but which could.
>
> Although OpenSSL uses many global data structures, all i have to do is
> use the proper compiler to build OpenSSL with multithread options.
> ...for having it built with multithread-supprt this is sufficient, but
> as soon as you know your application gets multithreaded (whether you
> spawn threads by your own or you use some library-functions which does
> this for you (implicitly)...for example using the multi-interface from
> libcurl should be enough) it is a must to "give" the OpenSSL-Lib the
> callbacks to be able to lock their global datastructures, nevertheless
> your app would work without the locks very often or even nearly always,
> it is not relieable and not a good way to code. You probably/hopefully
> would use locking mechanism to protect data-access to your global
> datastrucutres if you would had some in *your* multithreaded
> application. Just because you dont't see the library's code which spawns
> threads and makes accesses to global data from this threads, it ist no
> good idea not to lock the accesses. You just risk having the whole
> application crashed in some day. And in this day you even might have
> forgotten about the locking issue, so I predict you wont' find the cause
> or even some indicators for it.
>
> Anyway, best wishes. If you need some help on how to provide those
> callbacks in a propriate way, just let know.
>
> Ciao, Frank.
Received on 2004-11-19