Subject: Re: Thread safety issues

Re: Thread safety issues

From: Simon Josefsson <simon_at_josefsson.org>
Date: Tue, 31 Aug 2010 21:54:58 +0200

jmk <jmk_at_foofus.net> writes:

> On Tue, 2010-08-31 at 09:53 +0200, Simon Josefsson wrote:
>> You shouldn't need any mutexes except the ones needed for the crypto
>> library. Maybe you could remove your own mutex and see if things
>> continue to work?
>
> It's certainly possible I've messed stuff up, but without the mutex for
> libssh2_session_init_ex(), things still occasionally blow up. With a
> mutex for that one call and the crypto callback functions, things *seem*
> completely stable.

Do you call libssh2_init? The libssh2_session_init_ex function
initializes the library when needed, maybe you cause two threads to
initialize the library at the same time. By doing an explicit
libssh2_init at the start of your program, that should be avoided.

It may also be that I've missed something, and libssh2_session_init_ex
is intended to be thread-unsafe too. But then we have a documentation
problem, since this is not stated in the function man page.

/Simon
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-08-31