rkitover/net-ssh2 — pull request #10 by jamessan (2013-01-17 19:47:05+00:00)
Title: Threading initialization for crypto libraries

While libssh2 is itself thread-safe, the underlying crypto library (OpenSSL or gcrypt) it is linked against needs to have specific initialization performed so it can safely be used in threaded environments. Without that setup, you can easily run into segfaults like [perl: ath.c:193: _gcry_ath_mutex_lock: Assertion `*lock == ((ath_mutex_t) 0)' failed.](http://www.perlmonks.org/?node_id=936201).

This patch series enables building Net::SSH2 when libssh2 is linked against libgcrypt, as well as performing the thread initialization for OpenSSL or libgcrypt. I relied heavily on how this is implemented in Net::SSLeay and Crypt::GCrypt, respectively. While there is code to handle this setup on Windows systems, my experience seems to be that Perl's threading implementation on Windows means this may not be necessary.