testbot/TestAgent: Fix handling of EAGAIN errors in _SendFile().

Francois Gouget fgouget at codeweavers.com
Fri Jan 25 07:48:26 CST 2013


We can get EAGAIN errors when tunneling through SSH, particularly for larger $BLOCK_SIZE values.
---

I believe this should fix the 'Resource temporarily unavailable' errors.


 testbot/lib/WineTestBot/TestAgent.pm |   54 +++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 23 deletions(-)

diff --git a/testbot/lib/WineTestBot/TestAgent.pm b/testbot/lib/WineTestBot/TestAgent.pm
index 2a6c001..e3b130c 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);
-- 
1.7.10.4



More information about the wine-patches mailing list