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

Re: multithread calls libssh2_session_handshake,error,return -13

From: Michael Kwasigroch <mkwasigr_at_intercope.com>
Date: Thu, 13 Feb 2014 10:28:41 +0100

Alfred,

(@ALL: sorry to hitchhike this thread)

in your configure call you use --with-XXX-prefix - this never worked for
me, neither in the stable nor the development versions of libssh2 on AIX,
Solaris and Linux.

Have you checked that the compiled libssh2.so was actually linked to the
shlibs in $HOME/...?

I still suspect that --with-XXX-prefix does not work in libssh2. The build
process always used the standard libs located in /usr/lib (or /usr/lib64
etc.) regardless of the settings of --with-XXX-prefix.

If you find the same we may get on to find and fix it (or file a bug
report for the configure experts).

Thanks!

Mit freundlichen Gruessen / best regards

Michael Kwasigroch
Development
_______________________________________________________________

Office number: +49 40 514 52-175
Office fax: +49 40 514 52-100
Email: mkwasigr_at_intercope.com

www.intercope.com



From: Alfred Gebert <alfred.gebert_at_gmail.com>
To: libssh2 development <libssh2-devel_at_cool.haxx.se>
Date: 13.02.2014 09:16
Subject: Re: multithread calls
libssh2_session_handshake,error,return -13
Sent by: "libssh2-devel" <libssh2-devel-bounces_at_cool.haxx.se>



On Wed, Feb 12, 2014 at 4:10 AM, xingzhiming <xingzhiming_at_gmail.com>
wrote:
>
> hi,all
> When using multiple threads, in libssh2_session_handshake abnormal.
> If you do not multi-threaded, no problem. How to use multi-thread
calls libssh2?
>

I had a similar problem. Perhaps my solution can you help as well.

If I created a session I got the error:
  Unable to exchange encryption keys

I enabled verbose logging and did run the application with truss
(similar to strace on Linux) on Solaris.

  /13: recv(11, 0xFFFFFD7FFBA05B17, 1, 0) Err#11 EAGAIN
  _libssh2_recv: rc=-1 errno=125
  [libssh2] 0.758411 Socket: Error recving 1 bytes: 125

On the first line above a recv() system call returned with -1 and
errno was 11 (EAGAIN). But on the second and third line errno was 125.
The second line is a debug output which I added to the source directly
after the recv() statement.

The source of the problem was that I didn't compile libssh2 with
correct compiler flags for multi-threading. If you do not pay
attention on Solaris then errno is a global variable. Using gcc
compiler you can add "-pthread" as compile and link flag to enable
thread local storage of errno. Using -D_REENTRANT on Solaris as
compile flag also works. My configure call is now is e.g.
  CFLAGS="-m64 -pthread" LDFLAGS="-m64 -pthread" ./configure
--with-openssl --with-libssl-prefix=$HOME/local --with-libz
--with-libz-prefix=$HOME/local --prefix=$HOME/local
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel


________________________________________________________________
INTERCOPE International Communication Products Engineering GmbH
Himmelstrasse 12-16, 22299 Hamburg, Germany
Managing Directors: Reinhart Laumer, Frank Kollender
Commercial Registry: Amtsgericht Hamburg, HRB 31 638
________________________________________________________________
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
________________________________________________________________

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2014-02-13