in reply to Re^2: Net::SSH2 exec timeout
in thread Net::SSH2 exec timeout

Why are you using a reference to the object instead of the object?


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.

Replies are listed 'Best First'.
Re^4: Net::SSH2 exec timeout
by £okì (Scribe) on Sep 08, 2011 at 22:48 UTC
    Sorry for the confusion, I tried both.

    First using the object directly I get the error: Thread 1 terminated abnormally: Can't call method "exec" on an undefined value at Configuration.pl

    Then, if I try to pass it in as a reference as it looks like $ssh is coming in undefined, I get the error: perl: ath.c:193: _gcry_ath_mutex_lock: Assertion `*lock == ((ath_mutex_t) 0)' failed.
      it looks like $ssh is coming in undefined,

      That doesn't happen with normal blessed objects:

      #! perl -slw use strict; use threads; package Test; sub new{ bless [], $_[0] } sub exec{ print 'exec method called from thread: ', threads->tid } package main; my $o = Test->new; $o->exec; async{ $o->exec; }->detach; sleep 1; $o->exec; __END__ c:\test>tobj exec method called from thread: 0 exec method called from thread: 1 exec method called from thread: 0

      Which probably means that there is some misbegotten code in Net::SSH2 that is attempting to make it "thread-safe".

      The next thing to try is creating the ssh object inside the thread:

      use threads; use Net::SSH2; async { my $ssh = Net::SSH2->new( ... ); $ssh->scp_put($firmware[$antenna_type],'/tmp/fwupdate.bin'); print "Upgrading firmware, this will take about 3 minutes.\n"; my $chan = $ssh->channel(); $chan->exec("/sbin/fwupdate -m\n"); $chan->close; }->detach; ...

      Again, that ought to work, but I have no way to test this speculation!


      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.
        Yeah, does seem like that. Trying to redefine $ssh inside the thread yeilds:
        Attempt to free non-existent shared string 'GEN0', Perl interpreter: 0 +x8990e48 at Configuration.pl line 41, <> line 3. Segmentation fault


        If I try to completely make up a whole new connection like so:
        async { my $ssh2 = Net::SSH2->new(); $ssh2->connect($host); $ssh2->auth_password($user,$password); print "Upgrading firmware, this will take about 3 minutes. +\n"; my $chan2 = $ssh2->channel(); $chan2->exec("/sbin/fwupdate -m\n"); $chan2->close; }->detach;

        I get this error:
        Attempt to free non-existent shared string 'GEN0', Perl interpreter: 0 +x83f4e98, <> line 3. Unbalanced string table refcount: (1) for "GEN0" during global destruc +tion. Unbalanced string table refcount: (1) for "/usr/share/perl/5.12/Symbol +.pm" during global destruction. Scalars leaked: -6


        This error is not fatal though but it apparently does not pass beyond this and my script hangs.