Skip to content

Commit

Permalink
No infinite loop on socket read error and EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
zby committed Oct 23, 2014
1 parent d2b8649 commit 0cd6a95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Munin/Node/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ sub read_list {
my ($self) = @_;
my @data;
my $line = $self->read;
while($line !~ /^\.$/) {
while($line !~ /^\.$/ and defined $line) {
chomp $line;
push(@data, $line);
$line = $self->read;
Expand Down
9 changes: 8 additions & 1 deletion t/Munin-Node-Client.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@

# change 'tests => 1' to 'tests => last_test_to_print';

use Test::More tests => 1;
use Test::More tests => 2;
BEGIN { use_ok('Munin::Node::Client') };


my $node = bless { socket => undef }, 'Munin::Node::Client';

alarm 1;
$node->read_list();
ok(1, 'No infinite loop on read error');

#########################

# Insert your test code below, the Test::More module is use()ed here so read
Expand Down

0 comments on commit 0cd6a95

Please sign in to comment.