Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi! I've been spending 2 days on trying to find a thread and SSH module that works together, but to no avail. You're my last hope.
I have a few hundred nodes running on GPRS links that I need to do some work on once in a while. Since GPRS are so damned slow, my ordinary approach of connecting one by one is not viable, thus I began looking on threading. However, when I run the example code posted below, I randomly run into this errormessage:
perl: ath.c:193: _gcry_ath_mutex_lock: Assertion `*lock == ((ath_mutex_t) 0)' failed.
4 of 5 times it exit early with that message, 1 in 5 it complete the job.
I've tried Net::SSH::Expect as well as Thread::Pool, Threads & Thread::Queue and any combination of those to no avail. Net::SSH::Expect behaved even worse.
I'm running this on perl 5.12.4 on Ubuntu 11.10. Please help me save the little hair I have left by pointing me in the direction of a possible solution. ;-)#!/usr/bin/perl use Thread::Pool; use Net::SSH2; use strict; open (MYINPUTELEMENTS, "./list.txt"); my $pool = Thread::Pool->new( { workers => 10, do => \&worker_parse, }); while (my $element = <MYINPUTELEMENTS>) { if ($element =~ /(\d+)(\.\d+){3}/) { $pool->job($element); } } close (MYINPUTELEMENTS); $pool->shutdown; sub worker_parse { my $inIP = $_[0]; chomp($inIP); my $ssh2 = Net::SSH2->new(); if ($ssh2->connect($inIP)) { if ($ssh2->auth_password('user','pass')) { my $gssChannel = $ssh2->channel(); $gssChannel->exec('ls -l / | wc -l'); my $gssData; my $gssLen = $gssChannel->read($gssData,8192); chomp($gssData); print "gss: $gssData - "; $gssChannel->close; my $lcsChannel = $ssh2->channel(); $lcsChannel->exec('ls -l /etc | wc -l'); my $lcs2Data; my $lcs2Len = $lcsChannel->read($lcs2Data,8192); chomp($lcs2Data); print "lcs2: $lcs2Data\n"; $lcsChannel->close; $ssh2->disconnect; } else { print "Authentication Failed\n"; } } else { print "Connection Failed\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::SSH2 not thread safe?
by syphilis (Archbishop) on Nov 06, 2011 at 01:10 UTC | |
|
Re: Net::SSH2 not thread safe?
by onelesd (Pilgrim) on Nov 06, 2011 at 02:18 UTC | |
by Anonymous Monk on Nov 06, 2011 at 12:35 UTC | |
|
Re: Net::SSH2 not thread safe?
by salva (Canon) on Nov 06, 2011 at 08:11 UTC | |
by Anonymous Monk on Nov 06, 2011 at 12:39 UTC | |
by salva (Canon) on Nov 06, 2011 at 18:00 UTC | |
|
Re: Net::SSH2 not thread safe?
by BrowserUk (Patriarch) on Nov 06, 2011 at 09:40 UTC | |
by Anonymous Monk on Nov 06, 2011 at 12:42 UTC | |
by BrowserUk (Patriarch) on Nov 06, 2011 at 13:35 UTC | |
|
Re: Net::SSH2 not thread safe?
by zentara (Cardinal) on Nov 06, 2011 at 11:49 UTC | |
by Anonymous Monk on Nov 06, 2011 at 12:59 UTC |