Skip to content

Commit

Permalink
Revert "Fix EINTR interruption in sysread for getline method."
Browse files Browse the repository at this point in the history
This reverts 34e32c1, f29ac3c and a933eb5 in the light of problems
reported in CPAN RT#133912.
  • Loading branch information
steve-m-hay committed Dec 23, 2020
1 parent d62decf commit f81a8b5
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions lib/Net/Cmd.pm
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,15 @@ sub getline {
my $rin = "";
vec($rin, $fd, 1) = 1;

my $timeout = $cmd->timeout || undef;
my $initial = time;
my $pending = $timeout;

my $buf;

until (scalar(@{${*$cmd}{'net_cmd_lines'}})) {
my $timeout = $cmd->timeout || undef;
my $rout;

my $select_ret = select($rout = $rin, undef, undef, $pending);
if (defined $select_ret and $select_ret > 0) {
my $r = sysread($cmd, $buf = "", 1024);
if (! defined($r) ) {
my $select_ret = select($rout = $rin, undef, undef, $timeout);
if ($select_ret > 0) {
unless (sysread($cmd, $buf = "", 1024)) {
my $err = $!;
$cmd->close;
$cmd->_set_status_closed($err);
Expand All @@ -363,20 +359,6 @@ sub getline {
push(@{${*$cmd}{'net_cmd_lines'}}, map {"$_\n"} @buf);

}
elsif (defined $select_ret && $select_ret == -1) {
if ( $! == EINTR ) {
if ( defined($timeout) ) {
redo if ($pending = $timeout - ( time - $initial ) ) > 0;
$cmd->_set_status_timeout;
return;
}
redo;
}
my $err = $!;
$cmd->close;
$cmd->_set_status_closed($err);
return;
}
else {
$cmd->_set_status_timeout;
return;
Expand Down

0 comments on commit f81a8b5

Please sign in to comment.