Subject: | Handles to sockets are not released |
Date: | Mon, 17 Mar 2008 11:56:58 +0100 |
To: | bug-Net-SSH2 [...] rt.cpan.org |
From: | r.liebig [...] telenet-ag.de |
Using Net::SSH2 Version 0.18 following program does not release
handles properly.
------------------------------------------------------------------------------------------------------------
use Net::SSH2;
$host="host";
$user="user";
$pass="pass";
for(my $i=0; $i < 100; ++$i){
print "Doing round $i\n";
my $ssh2 = Net::SSH2->new;
my $rc=$ssh2->connect($host);
print "rc=$rc\n";
$ssh2->poll(250);
my $type=$ssh2->auth(username => $user, password => $pass);
print "type=$type\n";
my $chan = $ssh2->channel();
$chan->blocking(0);
$chan->shell();
print $chan 'hostname'."\n";
print $chan 'hostname'."\n";
print $chan 'cat /etc/passwd'."\n";
while(<$chan>) {
print ;
}
print $chan 'exit';
$ssh2->disconnect;
$ssh2 = undef;
sleep 10;
}
------------------------------------------------------------------------------------------------------------
Using the unix-command pfiles following statements can be seen:
10: S_IFSOCK mode:0666 dev:258,0 ino:25969 uid:0 gid:0 size:0
O_RDWR|O_NONBLOCK FD_CLOEXEC
sockname: AF_INET 0.0.0.0 port: 0
11: S_IFSOCK mode:0666 dev:258,0 ino:26416 uid:0 gid:0 size:0
O_RDWR|O_NONBLOCK FD_CLOEXEC
sockname: AF_INET 193.96.234.131 port: 55584
peername: AF_INET 193.96.234.132 port: 22
With every round a handle like handle 11 above turns into one like handle
10 which is kept forever. If the disconnect
statement above is dropped, the handle 11 stays as is. By means the
handle is not closed properly.
This behaviour is only recognised, if just user and password are used.
Mit freundlichen Grüßen
Rainer Liebig