From a962e12744c914cc2c0fc12d224bde5fd67ca432 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 2 Jan 2010 16:45:05 -0600 Subject: cleanups --- dist.ini | 1 + lib/IO/Socket/Telnet/HalfDuplex.pm | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dist.ini b/dist.ini index 384129a..5ea2ad7 100644 --- a/dist.ini +++ b/dist.ini @@ -9,3 +9,4 @@ abstract = more reliable telnet communication [Prereq] IO::Socket::Telnet = 0 +Try::Tiny = 0 diff --git a/lib/IO/Socket/Telnet/HalfDuplex.pm b/lib/IO/Socket/Telnet/HalfDuplex.pm index 87fb383..85c1e2f 100644 --- a/lib/IO/Socket/Telnet/HalfDuplex.pm +++ b/lib/IO/Socket/Telnet/HalfDuplex.pm @@ -1,7 +1,8 @@ +package IO::Socket::Telnet::HalfDuplex; use strict; use warnings; -package IO::Socket::Telnet::HalfDuplex; use base 'IO::Socket::Telnet'; +use Try::Tiny; =head1 NAME @@ -94,7 +95,7 @@ sub read { $self->do(chr(${*{$self}}{ping_option})); ${*{$self}}{got_pong} = 0; - eval { + try { local $SIG{__DIE__}; while (1) { @@ -106,10 +107,11 @@ sub read { }; die "Disconnected from server: $!" unless $!{EINTR}; } + } + catch { + die $_ if $_ !~ /^got pong\n/; }; - die $@ if $@ !~ /^got pong\n/; - return $buffer; } -- cgit v1.2.3-54-g00ecf