www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: multithread calls libssh2_session_handshake,error,return -13

Re: multithread calls libssh2_session_handshake,error,return -13

From: Alexander Lamaison <swish_at_lammy.co.uk>
Date: Wed, 12 Feb 2014 18:51:06 +0000

On 12 February 2014 18:09, Peter Stuge <peter_at_stuge.se> wrote:
> xingzhiming wrote:
>> How to use multi-thread calls libssh2?
> Protect all calls which use the same session with a mutex.

At a quick glance, the OP's code doesn't share sessions between
threads, so it's more likely an issue with multiple threads calling
the crypto backend. In particular libssh2_init is not thread safe,
but the OP calls this in the worker thread. Instead they should call
it once for the entire program before spawning any worker threads.


Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org)
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2014-02-12

the libssh2 team