[#11073] segfault printing instruction sequence for iterator — <noreply@...>

Bugs item #10527, was opened at 2007-05-02 14:42

14 messages 2007/05/02
[#11142] Re: [ ruby-Bugs-10527 ] segfault printing instruction sequence for iterator — Nobuyoshi Nakada <nobu@...> 2007/05/10

Hi,

[#11188] Re: [ ruby-Bugs-10527 ] segfault printing instruction sequence for iterator — Paul Brannan <pbrannan@...> 2007/05/16

On Thu, May 10, 2007 at 04:51:18PM +0900, Nobuyoshi Nakada wrote:

[#11234] Planning to release 1.8.6 errata — Urabe Shyouhei <shyouhei@...>

Hi all.

17 messages 2007/05/25

Net::Telnet and EOF

From: Brian Candler <B.Candler@...>
Date: 2007-05-31 11:27:27 UTC
List: ruby-core #11373
I've noticed what appears to be an inconsistency in the behaviour of
Net::Telnet's waitfor() method.

If a timeout occurs while waiting for a match, a TimeoutError is raised (and
any data received so far is lost).

However, if the remote end disconnects while waiting for a match, no error
is generated, and the data received so far is returned. It explicitly
rescues EOFError to do this.

This leads to difficult usage, because if you do

    @telnet.waitfor(/prompt/)

and it returns, it could mean one of two things: either the string you were
waiting for was matched, or it wasn't matched and the far end disconnected.
The first is what you expect, and the second is likely to be an error
condition.

So I find that every waitfor call has to be wrapped, e.g.

    res = @telnet.waitfor(/prompt/)
    unless /prompt/ =~ res
      raise EOFError  # or handle this situation some other way
    end

Now, perhaps the current behaviour is useful in some situations - you telnet
to a device, issue a command, and it returns some data and disconnects. But
I'd like to be able to say explicitly this is what should happen, e.g.

    @telnet.waitfor(nil)
or
    @telnet.waitfor(:eof)

However you'd have to have an option to Net::Telnet.new to enable this
behaviour, to maintain backwards compatibility.

Does anyone have any thoughts on this?

Thanks,

Brian.

In This Thread

Prev Next