Forum: Ruby-core [ruby-trunk - Bug #8668][Open] Net::Telnet waitfor('Waittime'=>0) may wait forever

0df97f1810ea2ec7aed10034aebbfaf4?d=identicon&s=25 scottj97 (Scott Johnson) (Guest)
on 2013-07-23 05:41
(Received via mailing list)
Issue #8668 has been reported by scottj97 (Scott Johnson).

----------------------------------------
Bug #8668: Net::Telnet waitfor('Waittime'=>0) may wait forever
https://bugs.ruby-lang.org/issues/8668

Author: scottj97 (Scott Johnson)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674)
[armv6l-linux-eabihf]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


waitfor('Waittime'=>0) says it will not wait once the expected prompt
has matched, yet if the remote end continues to send data, it will in
fact wait, possibly forever.

Line 555 of net/telnet.rb (from 2.0.0) is:

      until(prompt === line and not IO::select([@sock], nil, nil,
waittime))

Which means even though prompt has matched, it will still call
IO::select, and if new data has arrived, it will make another pass
through this loop. In my case there is constantly new data arriving
(though it is only telnet control data) and so the loop never exits even
though the prompt was matched long ago.

I fixed this with:

      until(prompt === line and (waittime==0 or not IO::select([@sock],
nil, nil, waittime)))

Though I don't know what other implications that change might have.
0df97f1810ea2ec7aed10034aebbfaf4?d=identicon&s=25 scottj97 (Scott Johnson) (Guest)
on 2013-07-24 05:49
(Received via mailing list)
Issue #8668 has been updated by scottj97 (Scott Johnson).


There is a related bug with 'Timeout': if the remote end keeps sending
data (even if only telnet control codes), but it never matches the
prompt, waitfor() will wait forever.
----------------------------------------
Bug #8668: Net::Telnet waitfor('Waittime'=>0) may wait forever
https://bugs.ruby-lang.org/issues/8668#change-40639

Author: scottj97 (Scott Johnson)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674)
[armv6l-linux-eabihf]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


waitfor('Waittime'=>0) says it will not wait once the expected prompt
has matched, yet if the remote end continues to send data, it will in
fact wait, possibly forever.

Line 555 of net/telnet.rb (from 2.0.0) is:

      until(prompt === line and not IO::select([@sock], nil, nil,
waittime))

Which means even though prompt has matched, it will still call
IO::select, and if new data has arrived, it will make another pass
through this loop. In my case there is constantly new data arriving
(though it is only telnet control data) and so the loop never exits even
though the prompt was matched long ago.

I fixed this with:

      until(prompt === line and (waittime==0 or not IO::select([@sock],
nil, nil, waittime)))

Though I don't know what other implications that change might have.
This topic is locked and can not be replied to.