Subject: Re: Huge problem with ares_library_init() and ares_library_cleanup()

Re: Huge problem with ares_library_init() and ares_library_cleanup()

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 12 Jul 2010 18:08:18 +0200 (CEST)

On Wed, 7 Jul 2010, Vitaly Kruglikov wrote:

> prior to upgrading to the newer version of c-ares, I consulted c-ares
> documentation and discovered two new functions that pose a huge problem to
> users of the library: ares_library_init() and ares_library_cleanup().
>
> Both functions are defined as 'not thread-safe' and have to be executed
> before starting any other threads (ares_library_init) and after terminating
> all threads (ares_library_cleanup).
>
> This makes it impossibly to use the c-ares library safely by plug-ins in a
> multi-threaded process. Since a multi-threaded process that employs
> plug-ins (e.g., dynamically-loaded shared libraries) doesn't know which
> libraries will be used by dynamically-discovered/dynamically-loaded
> plug-ins, there is no safe way to initialize c-ares.
>
> Please, please provide a thread-safe, re-entrant initialization/cleanup
> mechanism that allows this incredibly useful library to be used under the
> above-described, fairly common circumstances (without forcing the overhead
> of static linking).

These functions are declared non-treadsafe as this is very common and typical
by initialization/cleanup mechanisms. We can see this in lots of other libs.

We're of course always interested in improving the lib so feel free to bring
on your code/patches and we'll discuss them!

-- 
  / daniel.haxx.se
Received on 2010-07-12