Net-SSH-Perl - Re: Bug in Channel.pm when stdin length is just right

Posted on Mon Aug 15 17:06:00 2005 by cmv in response to 873 (See the whole thread of 6)
Re: Bug in Channel.pm when stdin length is just right
I've found the bug, and have fixed it as described below. I don't think this is the best way to fix it, but it did prove my theory on how the bug was occuring. The problem occurs due to the interaction between drain_outgoing (in Channel.pm) and client_loop in (SSH2.pm). If your $stdout is bigger than remote_maxpacket, drain_outgoing tries to repeatedly call client_loop until the length is reduced to zero. The problem is that client_loop will not return back to drain_outgoing, once it is called from inside the while loop the second time. MY FIX: I reasoned that if I could force the client_loop to execute one-and-only-one-time, for each time it was called from the drain_outgoing while loop, there would be no problem. To test this, I did the following:
1.) drain_outgoing: added the following line before the while loop
$c->{ssh}->{DoOneLoop}=1;
2.) drain_outgoing: added the following line after the while loop
undef($c->{ssh}->{DoOneLoop});
3.) client_loop: added the following line just before the end of the first while loop
last if($ssh->{DoOneLoop});
This seems to have fixed it for all scenarios that I've tested.
Please let me know if there is a better way to fix this, and how we can get the fix officially into the module.
-Craig
Direct Responses: 970 | Write a response