Module: tools Branch: master Commit: 070fa93c111a22903b8c0403643f0a8e17524603 URL: http://source.winehq.org/git/tools.git/?a=commit;h=070fa93c111a22903b8c04036...
Author: Francois Gouget fgouget@codeweavers.com Date: Fri Jan 25 14:48:26 2013 +0100
testbot/TestAgent: Fix handling of EAGAIN errors in _SendFile().
We can get EAGAIN errors when tunneling through SSH, particularly for larger $BLOCK_SIZE values.
---
testbot/lib/WineTestBot/TestAgent.pm | 54 +++++++++++++++++++-------------- 1 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/testbot/lib/WineTestBot/TestAgent.pm b/testbot/lib/WineTestBot/TestAgent.pm index 6b8bff7..f06bd71 100644 --- a/testbot/lib/WineTestBot/TestAgent.pm +++ b/testbot/lib/WineTestBot/TestAgent.pm @@ -556,6 +556,32 @@ sub _RecvErrorList($) # Low-level functions to send raw data #
+sub _Write($$) +{ + my ($self, $Data) = @_; + return undef if (!defined $self->{fd}); + + my $Size = length($Data); + my $Sent = 0; + while ($Size) + { + my $w = syswrite($self->{fd}, $Data, $Size, $Sent); + if (!defined $w) + { + $self->_SetError($FATAL, "network write error: $!"); + return undef; + } + if ($w == 0) + { + $self->_SetError($FATAL, "unable to send more data"); + return $Sent; + } + $Sent += $w; + $Size -= $w; + } + return $Sent; +} + sub _SendRawData($$) { my ($self, $Data) = @_; @@ -566,29 +592,11 @@ sub _SendRawData($$) { local $SIG{ALRM} = sub { die "timeout" }; $self->_SetAlarm(); - - my $Size = length($Data); - my $Pos = 0; - while ($Size) - { - my $n = syswrite($self->{fd}, $Data, $Size, $Pos); - if (!defined $n) - { - alarm(0); - $self->_SetError($FATAL, "network write error: $!"); - return; - } - if ($n == 0) - { - alarm(0); - $self->_SetError($FATAL, "unable to send more data"); - return; - } - $Pos += $n; - $Size -= $n; - } + $self->_Write($Data); alarm(0); - $Success = 1; + + # _Write() errors are fatal and break the connection + $Success = 1 if (defined $self->{fd}); }; if ($@) { @@ -694,7 +702,7 @@ sub _SendFile($$$) return; } $Size -= $r; - my $w = syswrite($self->{fd}, $Buffer, $r, 0); + my $w = $self->_Write($Buffer); if (!defined $w or $w != $r) { alarm(0);