Hi, On Thu, Mar 31, 2022 at 04:00:16PM +0300, Catalin Raceanu via curl-library wrote: > On 31-Mar-22 15:04, Mark Wielaard wrote: > > whether there is a thread-safe way to call > > curl_global_init at a later time (to get rid of the library constructor > > init function). > > I believe that this is an exact fit for C==11's std::call_once(). Boost also > has an equivalent, that most likely predates the other, in case older c++ > standard is used.
Thanks. Our library is pure C, but we can probably rely on pthread_once if it is allowable to call curl_global_init at a later time when multiple threads are already running. The reason we aren't doing that now is because the curl_global_init documentation explicitly states "You must not call it when any other thread in the program is running". But maybe we are interpreting the documentation too strictly? Are there examples of other libraries using libcurl which do this global initialization lazily from which we can steal some code? Thanks, Mark