Sad Clouds wrote:

> I think pretty much every Unix platform standardised on Posix threads
> by now. Using locking implies that you're using threads, and that is
> Pthreads API on Unix.

Just because you are using threads and on a platform that supports native
threads, it does not follow that you are using the native threading API.
 
> Non Unix platforms should be dealt with on individual basis, using
> whatever native threading/locking primitives they provide.

How will that work if the application isn't using the native threading API?
 
> I still think it's library's responsibility to pick the most efficient
> locking primitives for a given platform and use them transparently,
> without exposing the semantics to the application code.

The locking primitives aren't for the platform, they're for the threading
model. What you're suggesting would require one library version for each
threading model.

> What happens if
> your application is linked to other libraries which use OpenSSL and try
> to set their own locking callbacks?

What happens if your application is linked to other libraries that are
compiled for native threads and you are using an alternative threading API?
What happens if your application is multi-threaded and links to a
single-threaded library? An application has to coordinate its library use.
These decisions *have* to be made at the application-level or things will
break.
 
> I have a feeling the locking callbacks mechanism is the leftover from
> the 90s era.

I use OpenSSL on platforms where I have my own threading primitives that are
different from the platform's native ones. I can still use the same OpenSSL
library everything else uses. If not for the locking callback mechanism, I'd
have to hack OpenSSL to make it work.

I can also track OpenSSL's lock and memory usage very easily in debug builds
because I can add wrappers to its invocation of those functions. If OpenSSL
called the platform's native functions for these purposes, that would be
much harder to do.

And there are still platforms where you can multi-thread, but there is *no*
native threading API. And there are platforms where threading primitives
have high overhead that's not needed in single-threaded applications.

This is something OpenSSL does right.

DS



______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to