[DRE-maint] Bug#714606: help with fixing ruby-net-ssh: can't add a new key into hash during iteration during ssh.exec
David Suarez
david.sephirot at gmail.com
Tue Apr 14 12:39:04 UTC 2015
Hi,
2015-04-14 13:00 GMT+02:00 Martin Steigerwald <ms at teamix.de>:
> Am Dienstag, 14. April 2015, 12:36:33 schrieb Martin Steigerwald:
>> Cc'ing the bug report as well, feel free to drop the cc for discussion on mailing list.
>> an each in session.rb, line 222.
>>
>>
>> Which looks quite central to the working of ruby-net-ssh to me
>>
>> # This is called internally as part of #process. It dispatches any
>> # available incoming packets, and then runs Net::SSH::Connection::Channel#process
>> # for any active channels. If a block is given, it is invoked at the
>> # start of the method and again at the end, and if the block ever returns
>> # false, this method returns false. Otherwise, it returns true.
>> def preprocess
>> return false if block_given? && !yield(self)
>> dispatch_incoming_packets
>> channels.each { |id, channel| channel.process unless channel.closing? }
>> return false if block_given? && !yield(self)
>> return true
>> end
>>
>>
>>
>> The calling site inside distkeys is:
>>
>> https://github.com/teamix/distkeys/blob/master/distkeys#L174
>>
You are right, 'channels' Hash is modified inside 'channels.each' call.
> I am not sure whether it is a work-around or whether it is a valid
> contraint to be taken into account when using ruby-net-ssh. To me it
> feels like a work-around, but well… if it works this way.
>
> If you still have an idea how to fix it in ruby-net-ssh, please tell me.
Seems like a valid constrain, due that the problem arise when you are
trying to open a new channel (ssh.exec!) inside the processing block
of the another channel (sftp.lstat) in the same ssh session.
One fix could be that instead os reusing the actual ssh connection to
open the sftp one ""@sftp = Net::SFTP::Session.new(@ssh)"", create a
new sftp connection ""Net::SFTP.start(host, user, options)"".
Cheers,
David
More information about the Pkg-ruby-extras-maintainers
mailing list