Subject: Re: Thread safety issues

Re: Thread safety issues

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 30 Aug 2010 16:45:26 +0200 (CEST)

On Mon, 30 Aug 2010, Michel Valin wrote:

> 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

Right, libssh2 doesn't need a thread library so it doesn't check for or use
one. Also, at least in *nix land it is also quite possible that the
application is using its own mutex or thread library and it's hard for libssh2
to know which to use.

Therefore, we try to document that libssh2_init is not thread safe so that
applications that use threads can do that mutexing instead.

Of course, thiis doesn't have to be like this forever, it is just how things
work now. If you have ideas and suggestions on how to behave instead, please
let us know.

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