Subject: Re: Thread safety issues

Re: Thread safety issues

From: Michel Valin <>
Date: Mon, 30 Aug 2010 10:10:48 -0400

potentially dumb question/suggestion:

why not put a mutex lock in libssh2_init() ?

or have a libssh2_init_safe() wrapper with mutex aroud it ?

on the down side this would force to always link with the thread library

Daniel Stenberg wrote:
> On Mon, 30 Aug 2010, Jose Baars wrote:
>> Wouldn't the libssh2_init function be one of the prime suspects? This
>> function was added in libssh2 1.2.7.
> Quoted from the man page for libssh2_init():
> It uses a global state, and is not thread safe -- you must
> make sure this function is not called concurrently.
> ... and before anyone questions the reasoning for this let me exaplain
> that the underlying libraries (OpenSSL or libgcrypt) both have non
> thread-safe init functions themselves that libssh2 need to use.
> Thus, 1.2.7 is actually more thread-safe than previously as now it
> offers a way for the app to do these things in a controlled manner.

Received on 2010-08-30