BTW, I tried moving the connect inside of opener(). The open now succeeds, but the authentication now segfaults.
What you've conclusively proved is that either Net::SSH2, or more likely, the underlying C libraries it uses, are not reentrant. Ie. Not threadsafe.
There is something wrong with using shared handle outside the thread.
Nope. The main thread of a process is a thread just like any other threads you create.
You will just have to accept that there is nothing you can do to fix or work around the problems of the module and its underlying libraries.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
@BrowserUK: Thank you. It is not the conclusion I wanted to prove, but I agree it is something I will have to accept, until such time someone has the resources to determine why Net::SSH2 (or the underlying libssh2 library) is not completely ithread safe. I am glad we can all now finally agree that Net::SSH2 should not be used with Perl threads, unless the entire life of a session resides within a thread (connect, auth, commands, and close). Much appreciated!
Update: I plan to give Salva's suggestion a try, but not until after I finish with my Net::OpenSSH test...
"The trick would be to call $ssh2->blocking(0) just after creating the Net::SSH2 object and then calling connect and auth_* while checking for LIBSSH2_ERROR_EAGAIN errors and then using the select function to wait for data to arrive at some of the underlaying sockets."
| [reply] |
| [reply] |