[5/5] testbot/TestAgent: Track the current RPC and argument name and include them in error messages.
Francois Gouget
fgouget at codeweavers.com
Wed Mar 12 08:52:42 CDT 2014
Also keep track of how many bytes were written/read before the error occurred.
This helps diagnose errors. In particular, should a 'network read timeout' occur, it helps knowing where it happened.
---
testbot/lib/WineTestBot/TestAgent.pm | 360 ++++++++++++++++++-----------------
1 file changed, 189 insertions(+), 171 deletions(-)
diff --git a/testbot/lib/WineTestBot/TestAgent.pm b/testbot/lib/WineTestBot/TestAgent.pm
index d17336e..2b18616 100644
--- a/testbot/lib/WineTestBot/TestAgent.pm
+++ b/testbot/lib/WineTestBot/TestAgent.pm
@@ -222,8 +222,7 @@ sub _SetError($$$)
# We did not even manage to connect but record the error anyway
$self->{err} = $Msg;
}
- my $RpcName = defined $self->{rpcid} ? $RpcNames{$self->{rpcid}} || $self->{rpcid} : "Connect";
- debug("$RpcName: $self->{err}\n");
+ debug($self->{rpc} || "norpc", ": $self->{err}\n");
}
sub GetLastError($)
@@ -237,43 +236,45 @@ sub GetLastError($)
# Low-level functions to receive raw data
#
-sub _RecvRawData($$)
+sub _RecvRawData($$$)
{
- my ($self, $Size) = @_;
+ my ($self, $Name, $Size) = @_;
return undef if (!defined $self->{fd});
my $Result;
+ my ($Received, $Remaining) = (0, $Size);
eval
{
local $SIG{ALRM} = sub { die "timeout" };
$self->_SetAlarm();
my $Data = "";
- while ($Size)
+ while ($Remaining)
{
my $Buffer;
- my $r = $self->{fd}->read($Buffer, $Size);
+ my $r = $self->{fd}->read($Buffer, $Remaining);
if (!defined $r)
{
alarm(0);
- $self->_SetError($FATAL, "network read error: $!");
+ $self->_SetError($FATAL, "network read error ($self->{rpc}:$Name:$Received/$Size): $!");
return;
}
if ($r == 0)
{
alarm(0);
- $self->_SetError($FATAL, "got a premature network EOF");
+ $self->_SetError($FATAL, "network read got a premature EOF ($self->{rpc}:$Name:$Received/$Size)");
return;
}
$Data .= $Buffer;
- $Size -= $r;
+ $Received += $r;
+ $Remaining -= $r;
}
alarm(0);
$Result = $Data;
};
if ($@)
{
- $@ = "network read timed out" if ($@ =~ /^timeout /);
+ $@ = "network read timed out ($self->{rpc}:$Name:$Received/$Size)" if ($@ =~ /^timeout /);
$self->_SetError($FATAL, $@);
}
return $Result;
@@ -281,59 +282,61 @@ sub _RecvRawData($$)
sub _SkipRawData($$)
{
- my ($self, $Size) = @_;
+ my ($self, $Name, $Size) = @_;
return undef if (!defined $self->{fd});
my $Success;
+ my ($Received, $Remaining) = (0, $Size);
eval
{
local $SIG{ALRM} = sub { die "timeout" };
$self->_SetAlarm();
- while ($Size)
+ while ($Remaining)
{
my $Buffer;
- my $s = $Size < $BLOCK_SIZE ? $Size : $BLOCK_SIZE;
+ my $s = $Remaining < $BLOCK_SIZE ? $Remaining : $BLOCK_SIZE;
my $n = $self->{fd}->read($Buffer, $s);
if (!defined $n)
{
alarm(0);
- $self->_SetError($FATAL, "network skip failed: $!");
+ $self->_SetError($FATAL, "network skip failed ($self->{rpc}:$Name:$Received/$Size): $!");
return;
}
if ($n == 0)
{
alarm(0);
- $self->_SetError($FATAL, "got a premature network EOF");
+ $self->_SetError($FATAL, "network skip got a premature EOF ($self->{rpc}:$Name:$Received/$Size)");
return;
}
- $Size -= $n;
+ $Received += $n;
+ $Remaining -= $n;
}
alarm(0);
$Success = 1;
};
if ($@)
{
- $@ = "network skip timed out" if ($@ =~ /^timeout /);
+ $@ = "network skip timed out ($self->{rpc}:$Name:$Received/$Size)" if ($@ =~ /^timeout /);
$self->_SetError($FATAL, $@);
}
return $Success;
}
-sub _RecvRawUInt32($)
+sub _RecvRawUInt32($$)
{
- my ($self) = @_;
+ my ($self, $Name) = @_;
- my $Data = $self->_RecvRawData(4);
+ my $Data = $self->_RecvRawData($Name, 4);
return undef if (!defined $Data);
return unpack('N', $Data);
}
-sub _RecvRawUInt64($)
+sub _RecvRawUInt64($$)
{
- my ($self) = @_;
+ my ($self, $Name) = @_;
- my $Data = $self->_RecvRawData(8);
+ my $Data = $self->_RecvRawData($Name, 8);
return undef if (!defined $Data);
my ($High, $Low) = unpack('NN', $Data);
return $High << 32 | $Low;
@@ -346,28 +349,28 @@ sub _RecvRawUInt64($)
sub _RecvEntryHeader($)
{
- my ($self) = @_;
+ my ($self, $Name) = @_;
- my $Data = $self->_RecvRawData(9);
+ my $Data = $self->_RecvRawData("$Name.h", 9);
return (undef, undef) if (!defined $Data);
my ($Type, $High, $Low) = unpack('cNN', $Data);
$Type = chr($Type);
return ($Type, $High << 32 | $Low);
}
-sub _ExpectEntryHeader($$;$)
+sub _ExpectEntryHeader($$$;$)
{
- my ($self, $Type, $Size) = @_;
+ my ($self, $Name, $Type, $Size) = @_;
- my ($HType, $HSize) = $self->_RecvEntryHeader();
+ my ($HType, $HSize) = $self->_RecvEntryHeader($Name);
return undef if (!defined $HType);
if ($HType ne $Type)
{
- $self->_SetError($ERROR, "Expected a $Type entry but got $HType instead");
+ $self->_SetError($ERROR, "Expected $Name to be a $Type entry but got $HType instead");
}
elsif (defined $Size and $HSize != $Size)
{
- $self->_SetError($ERROR, "Expected an entry of size $Size but got $HSize instead");
+ $self->_SetError($ERROR, "Expected $Name to be of size $Size but got $HSize instead");
}
else
{
@@ -376,101 +379,101 @@ sub _ExpectEntryHeader($$;$)
if ($HType eq 'e')
{
# The expected data was replaced with an error message
- my $Message = $self->_RecvRawData($HSize);
+ my $Message = $self->_RecvRawData("$Name.e", $HSize);
return undef if (!defined $Message);
$self->_SetError($ERROR, $Message);
}
else
{
- $self->_SkipRawData($HSize);
+ $self->_SkipRawData($Name, $HSize);
}
return undef;
}
-sub _ExpectEntry($$$)
+sub _ExpectEntry($$$$)
{
- my ($self, $Type, $Size) = @_;
+ my ($self, $Name, $Type, $Size) = @_;
- $Size = $self->_ExpectEntryHeader($Type, $Size);
+ $Size = $self->_ExpectEntryHeader($Name, $Type, $Size);
return undef if (!defined $Size);
- return $self->_RecvRawData($Size);
+ return $self->_RecvRawData($Name, $Size);
}
-sub _RecvUInt32($)
+sub _RecvUInt32($$)
{
- my ($self) = @_;
+ my ($self, $Name) = @_;
- return undef if (!defined $self->_ExpectEntryHeader('I', 4));
- my $Value = $self->_RecvRawUInt32();
- debug(" RecvUInt32() -> $Value\n") if (defined $Value);
+ return undef if (!defined $self->_ExpectEntryHeader($Name, 'I', 4));
+ my $Value = $self->_RecvRawUInt32($Name);
+ debug(" RecvUInt32('$Name') -> $Value\n") if (defined $Value);
return $Value;
}
-sub _RecvUInt64($)
+sub _RecvUInt64($$)
{
- my ($self) = @_;
+ my ($self, $Name) = @_;
- return undef if (!defined $self->_ExpectEntryHeader('Q', 8));
- my $Value = $self->_RecvRawUInt64();
- debug(" RecvUInt64() -> $Value\n") if (defined $Value);
+ return undef if (!defined $self->_ExpectEntryHeader($Name, 'Q', 8));
+ my $Value = $self->_RecvRawUInt64($Name);
+ debug(" RecvUInt64('$Name') -> $Value\n") if (defined $Value);
return $Value;
}
-sub _RecvString($;$)
+sub _RecvString($$;$)
{
- my ($self, $EType) = @_;
+ my ($self, $Name, $EType) = @_;
- my $Str = $self->_ExpectEntry($EType || 's');
+ my $Str = $self->_ExpectEntry($Name, $EType || 's');
if (defined $Str)
{
# Remove the trailing '\0'
chop $Str;
- debug(" RecvString() -> '$Str'\n");
+ debug(" RecvString('$Name') -> '$Str'\n");
}
return $Str;
}
-sub _RecvFile($$$)
+sub _RecvFile($$$$)
{
- my ($self, $Dst, $Filename) = @_;
+ my ($self, $Name, $Dst, $Filename) = @_;
return undef if (!defined $self->{fd});
- debug(" RecvFile($Filename)\n");
+ debug(" RecvFile('$Name', '$Filename')\n");
- my $Size = $self->_ExpectEntryHeader('d');
+ my $Size = $self->_ExpectEntryHeader($Name, 'd');
return undef if (!defined $Size);
- my ($Bytes, $Start) = (0, now());
my $Success;
+ my ($Start, $Received, $Remaining) = (now(), 0, $Size);
eval
{
local $SIG{ALRM} = sub { die "timeout" };
$self->_SetAlarm();
- while ($Size)
+ while ($Remaining)
{
my $Buffer;
- my $s = $Size < $BLOCK_SIZE ? $Size : $BLOCK_SIZE;
+ my $s = $Remaining < $BLOCK_SIZE ? $Remaining : $BLOCK_SIZE;
my $r = $self->{fd}->read($Buffer, $s);
if (!defined $r)
{
alarm(0);
- $self->_SetError($FATAL, "got a network error while receiving '$Filename': $!");
+ $self->_SetError($FATAL, "got a network error while receiving '$Filename' ($self->{rpc}:$Name:$Received/$Size): $!");
return;
}
if ($r == 0)
{
alarm(0);
- $self->_SetError($FATAL, "got a premature EOF while receiving '$Filename'");
+ $self->_SetError($FATAL, "got a premature EOF while receiving '$Filename' ($self->{rpc}:$Name:$Received/$Size)");
return;
}
- $Size -= $r;
+ $Remaining -= $r;
my $w = syswrite($Dst, $Buffer, $r, 0);
- $Bytes += $w if (defined $w);
+ $Received += $w if (defined $w);
if (!defined $w or $w != $r)
{
alarm(0);
- $self->_SetError($ERROR, "an error occurred while writing to '$Filename': $!");
- $self->_SkipRawData($Size);
+ $self->_SetError($ERROR, "an error occurred while writing to '$Filename' ($self->{rpc}:$Name:$Received/$Size): $!");
+ $self->_SkipRawData($Name, $Remaining);
return;
}
}
@@ -479,11 +482,11 @@ sub _RecvFile($$$)
};
if ($@)
{
- $@ = "timed out while receiving '$Filename'" if ($@ =~ /^timeout /);
+ $@ = "timed out while receiving '$Filename' ($self->{rpc}:$Name:$Received/$Size)" if ($@ =~ /^timeout /);
$self->_SetError($FATAL, $@);
}
- trace_speed($Bytes, now() - $Start);
+ trace_speed($Received, now() - $Start);
return $Success;
}
@@ -492,32 +495,31 @@ sub _SkipEntries($$)
my ($self, $Count) = @_;
debug(" SkipEntries($Count)\n");
- while ($Count)
+ for (my $i = 0; $i < $Count; $i++)
{
- my ($Type, $Size) = $self->_RecvEntryHeader();
+ my ($Type, $Size) = $self->_RecvEntryHeader("Skip$i");
return undef if (!defined $Type);
if ($Type eq 'e')
{
# The expected data was replaced with an error message
- my $Message = $self->_RecvRawData($Size);
+ my $Message = $self->_RecvRawData("Skip$i.e", $Size);
return undef if (!defined $Message);
$self->_SetError($ERROR, $Message);
}
- elsif (!$self->_SkipRawData($Size))
+ elsif (!$self->_SkipRawData("Skip$i", $Size))
{
return undef;
}
- $Count--;
}
return 1;
}
-sub _RecvListSize($)
+sub _RecvListSize($$)
{
- my ($self) = @_;
+ my ($self, $Name) = @_;
- my $Value = $self->_RecvRawUInt32();
- debug(" RecvListSize() -> $Value\n") if (defined $Value);
+ my $Value = $self->_RecvRawUInt32($Name);
+ debug(" RecvListSize('$Name') -> $Value\n") if (defined $Value);
return $Value;
}
@@ -526,7 +528,7 @@ sub _RecvList($$)
my ($self, $ETypes) = @_;
debug(" RecvList($ETypes)\n");
- my $HCount = $self->_RecvListSize();
+ my $HCount = $self->_RecvListSize('ListSize');
return undef if (!defined $HCount);
my $Count = length($ETypes);
@@ -538,6 +540,7 @@ sub _RecvList($$)
}
my @List;
+ my $i = 0;
foreach my $EType (split //, $ETypes)
{
# '.' is a placeholder for data handled by the caller so let it handle
@@ -547,17 +550,17 @@ sub _RecvList($$)
my $Data;
if ($EType eq 'I')
{
- $Data = $self->_RecvUInt32();
+ $Data = $self->_RecvUInt32("List$i.I");
$Count--;
}
elsif ($EType eq 'Q')
{
- $Data = $self->_RecvUInt64();
+ $Data = $self->_RecvUInt64("List$i.Q");
$Count--;
}
elsif ($EType eq 's')
{
- $Data = $self->_RecvString();
+ $Data = $self->_RecvString("List$i.s");
$Count--;
}
else
@@ -570,6 +573,7 @@ sub _RecvList($$)
return undef;
}
push @List, $Data;
+ $i++;
}
return 1 if (!@List);
return $List[0] if (@List == 1);
@@ -580,14 +584,14 @@ sub _RecvErrorList($)
{
my ($self) = @_;
- my $Count = $self->_RecvListSize();
+ my $Count = $self->_RecvListSize('ErrCount');
return $self->GetLastError() if (!defined $Count);
return undef if (!$Count);
- my $Errors = [];
+ my ($Errors, $i) = ([], 0);
while ($Count--)
{
- my ($Type, $Size) = $self->_RecvEntryHeader();
+ my ($Type, $Size) = $self->_RecvEntryHeader("Err$i");
if ($Type eq 'u')
{
debug(" RecvUndef()\n");
@@ -595,7 +599,7 @@ sub _RecvErrorList($)
}
elsif ($Type eq 's')
{
- my $Status = $self->_RecvRawData($Size);
+ my $Status = $self->_RecvRawData("Err$i.s", $Size);
return $self->GetLastError() if (!defined $Status);
debug(" RecvStatus() -> '$Status'\n");
push @$Errors, $Status;
@@ -603,7 +607,7 @@ sub _RecvErrorList($)
elsif ($Type eq 'e')
{
# The expected data was replaced with an error message
- my $Message = $self->_RecvRawData($Size);
+ my $Message = $self->_RecvRawData("Err$i.e", $Size);
if (defined $Message)
{
debug(" RecvError() -> '$Message'\n");
@@ -615,10 +619,11 @@ sub _RecvErrorList($)
else
{
$self->_SetError($ERROR, "Expected an s, u or e entry but got $Type instead");
- $self->_SkipRawData($Size);
+ $self->_SkipRawData("Err$i.$Type", $Size);
$self->_SkipEntries($Count);
return $self->GetLastError();
}
+ $i++;
}
return $Errors;
}
@@ -628,35 +633,35 @@ sub _RecvErrorList($)
# Low-level functions to send raw data
#
-sub _Write($$)
+sub _Write($$$)
{
- my ($self, $Data) = @_;
+ my ($self, $Name, $Data) = @_;
return undef if (!defined $self->{fd});
my $Size = length($Data);
- my $Sent = 0;
- while ($Size)
+ my ($Sent, $Remaining) = (0, $Size);
+ while ($Remaining)
{
- my $w = syswrite($self->{fd}, $Data, $Size, $Sent);
+ my $w = syswrite($self->{fd}, $Data, $Remaining, $Sent);
if (!defined $w)
{
- $self->_SetError($FATAL, "network write error: $!");
+ $self->_SetError($FATAL, "network write error ($self->{rpc}:$Name:$Sent/$Size): $!");
return undef;
}
if ($w == 0)
{
- $self->_SetError($FATAL, "unable to send more data");
+ $self->_SetError($FATAL, "unable to send more data ($self->{rpc}:$Name:$Sent/$Size)");
return $Sent;
}
$Sent += $w;
- $Size -= $w;
+ $Remaining -= $w;
}
return $Sent;
}
-sub _SendRawData($$)
+sub _SendRawData($$$)
{
- my ($self, $Data) = @_;
+ my ($self, $Name, $Data) = @_;
return undef if (!defined $self->{fd});
my $Success;
@@ -664,7 +669,7 @@ sub _SendRawData($$)
{
local $SIG{ALRM} = sub { die "timeout" };
$self->_SetAlarm();
- $self->_Write($Data);
+ $self->_Write($Name, $Data);
alarm(0);
# _Write() errors are fatal and break the connection
@@ -672,25 +677,25 @@ sub _SendRawData($$)
};
if ($@)
{
- $@ = "network write timed out" if ($@ =~ /^timeout /);
+ $@ = "network write timed out ($self->{rpc}:$Name)" if ($@ =~ /^timeout /);
$self->_SetError($FATAL, $@);
}
return $Success;
}
-sub _SendRawUInt32($$)
+sub _SendRawUInt32($$$)
{
- my ($self, $Value) = @_;
+ my ($self, $Name, $Value) = @_;
- return $self->_SendRawData(pack('N', $Value));
+ return $self->_SendRawData($Name, pack('N', $Value));
}
-sub _SendRawUInt64($$)
+sub _SendRawUInt64($$$)
{
- my ($self, $Value) = @_;
+ my ($self, $Name, $Value) = @_;
my ($High, $Low) = ($Value >> 32, $Value & 0xffffffff);
- return $self->_SendRawData(pack('NN', $High, $Low));
+ return $self->_SendRawData($Name, pack('NN', $High, $Low));
}
@@ -698,88 +703,89 @@ sub _SendRawUInt64($$)
# Functions to send parameter lists
#
-sub _SendListSize($$)
+sub _SendListSize($$$)
{
- my ($self, $Size) = @_;
+ my ($self, $Name, $Size) = @_;
- debug(" SendListSize($Size)\n");
- return $self->_SendRawUInt32($Size);
+ debug(" SendListSize('$Name', $Size)\n");
+ return $self->_SendRawUInt32($Name, $Size);
}
-sub _SendEntryHeader($$$)
+sub _SendEntryHeader($$$$)
{
- my ($self, $Type, $Size) = @_;
+ my ($self, $Name, $Type, $Size) = @_;
my ($High, $Low) = ($Size >> 32, $Size & 0xffffffff);
- return $self->_SendRawData(pack('cNN', ord($Type), $High, $Low));
+ return $self->_SendRawData("$Name.h", pack('cNN', ord($Type), $High, $Low));
}
-sub _SendUInt32($$)
+sub _SendUInt32($$$)
{
- my ($self, $Value) = @_;
+ my ($self, $Name, $Value) = @_;
- debug(" SendUInt32($Value)\n");
- return $self->_SendEntryHeader('I', 4) &&
- $self->_SendRawUInt32($Value);
+ debug(" SendUInt32('$Name', $Value)\n");
+ return $self->_SendEntryHeader($Name, 'I', 4) &&
+ $self->_SendRawUInt32($Name, $Value);
}
-sub _SendUInt64($$)
+sub _SendUInt64($$$)
{
- my ($self, $Value) = @_;
+ my ($self, $Name, $Value) = @_;
- debug(" SendUInt64($Value)\n");
- return $self->_SendEntryHeader('Q', 8) &&
- $self->_SendRawUInt64($Value);
+ debug(" SendUInt64('$Name', $Value)\n");
+ return $self->_SendEntryHeader($Name, 'Q', 8) &&
+ $self->_SendRawUInt64($Name, $Value);
}
-sub _SendString($$;$)
+sub _SendString($$$;$)
{
- my ($self, $Str, $Type) = @_;
+ my ($self, $Name, $Str, $Type) = @_;
- debug(" SendString('$Str')\n");
+ debug(" SendString('$Name', '$Str')\n");
$Str .= "\0";
- return $self->_SendEntryHeader($Type || 's', length($Str)) &&
- $self->_SendRawData($Str);
+ return $self->_SendEntryHeader($Name, $Type || 's', length($Str)) &&
+ $self->_SendRawData($Name, $Str);
}
-sub _SendFile($$$)
+sub _SendFile($$$$)
{
- my ($self, $Src, $Filename) = @_;
+ my ($self, $Name, $Src, $Filename) = @_;
return undef if (!defined $self->{fd});
- debug(" SendFile($Filename)\n");
+ debug(" SendFile('$Name', '$Filename')\n");
- my ($Bytes, $Start) = (0, now());
+ my $Size = -s $Filename;
+ my ($Start, $Sent, $Remaining) = (now(), 0, $Size);
my $Success;
eval
{
local $SIG{ALRM} = sub { die "timeout" };
$self->_SetAlarm();
- my $Size = -s $Filename;
- return if (!$self->_SendEntryHeader('d', $Size));
- while ($Size)
+ return if (!$self->_SendEntryHeader($Name, 'd', $Size));
+ while ($Remaining)
{
my $Buffer;
- my $s = $Size < $BLOCK_SIZE ? $Size : $BLOCK_SIZE;
+ my $s = $Remaining < $BLOCK_SIZE ? $Remaining : $BLOCK_SIZE;
my $r = sysread($Src, $Buffer, $s);
if (!defined $r)
{
alarm(0);
- $self->_SetError($FATAL, "an error occurred while reading from '$Filename': $!");
+ $self->_SetError($FATAL, "an error occurred while reading from '$Filename' ($self->{rpc}:$Name:$Sent/$Size): $!");
return;
}
if ($r == 0)
{
alarm(0);
- $self->_SetError($FATAL, "got a premature EOF while reading from '$Filename'");
+ $self->_SetError($FATAL, "got a premature EOF while reading from '$Filename' ($self->{rpc}:$Name:$Sent/$Size)");
return;
}
- $Size -= $r;
- my $w = $self->_Write($Buffer);
+ $Remaining -= $r;
+ my $w = $self->_Write($Name, $Buffer);
+ $Sent += $w if (defined $w);
if (!defined $w or $w != $r)
{
alarm(0);
- $self->_SetError($FATAL, "got a network error while sending '$Filename': $!");
+ $self->_SetError($FATAL, "got a network error while sending '$Filename' ($self->{rpc}:$Name:$Sent+$s/$Size): $!");
return;
}
}
@@ -788,11 +794,11 @@ sub _SendFile($$$)
};
if ($@)
{
- $@ = "timed out while sending '$Filename'" if ($@ =~ /^timeout /);
+ $@ = "timed out while sending '$Filename' ($self->{rpc}:$Name:$Sent/$Size)" if ($@ =~ /^timeout /);
$self->_SetError($FATAL, $@);
}
- trace_speed($Bytes, now() - $Start);
+ trace_speed($Sent, now() - $Start);
return $Success;
}
@@ -830,6 +836,9 @@ sub _Connect($)
{
my ($self) = @_;
+ my $OldRPC = $self->{rpc};
+ $self->{rpc} = "Connect";
+
my $Step;
foreach my $Dummy (1..$self->{cattempts})
{
@@ -942,7 +951,7 @@ sub _Connect($)
# Get the protocol version supported by the server.
# This also lets us verify that the connection really works.
$Step = "agent_version";
- $self->{agentversion} = $self->_RecvString();
+ $self->{agentversion} = $self->_RecvString('AgentVersion');
if (!defined $self->{agentversion})
{
alarm(0);
@@ -954,7 +963,11 @@ sub _Connect($)
alarm(0);
$Step = "done";
};
- return 1 if ($Step eq "done");
+ if ($Step eq "done")
+ {
+ $self->{rpc} = $OldRPC;
+ return 1;
+ }
if ($@)
{
$self->_SetError($FATAL, "Timed out in $Step while connecting to $self->{connection}");
@@ -963,6 +976,7 @@ sub _Connect($)
# permanent, like a hostname that does not resolve.
sleep(1);
}
+ $self->{rpc} = $OldRPC;
return undef;
}
@@ -971,12 +985,12 @@ sub _StartRPC($$)
my ($self, $RpcId) = @_;
# Set up the new RPC
- $self->{rpcid} = $RpcId;
+ $self->{rpc} = $RpcNames{$RpcId} || $RpcId;
$self->{err} = undef;
# First assume all is well and that we already have a working connection
$self->{deadline} = $self->{timeout} ? time() + $self->{timeout} : undef;
- if (!$self->_SendRawUInt32($RpcId))
+ if (!$self->_SendRawUInt32('RpcId.1', $RpcId))
{
# No dice, clean up whatever was left of the old connection
$self->Disconnect();
@@ -985,9 +999,9 @@ sub _StartRPC($$)
return undef if (!$self->_Connect());
debug("Using protocol '$self->{agentversion}'\n");
- # Reconnecting reset the operation deadline
+ # Reconnecting resets the operation deadline
$self->{deadline} = $self->{timeout} ? time() + $self->{timeout} : undef;
- return $self->_SendRawUInt32($RpcId);
+ return $self->_SendRawUInt32('RpcId.2', $RpcId);
}
return 1;
}
@@ -1003,7 +1017,7 @@ sub Ping($)
# Send the RPC and get the reply
return $self->_StartRPC($RPC_PING) &&
- $self->_SendListSize(0) &&
+ $self->_SendListSize('ArgC', 0) &&
$self->_RecvList('');
}
@@ -1029,11 +1043,11 @@ sub _SendStringOrFile($$$$$$)
# Send the RPC and get the reply
return $self->_StartRPC($RPC_SENDFILE) &&
- $self->_SendListSize(3) &&
- $self->_SendString($ServerPathName) &&
- $self->_SendUInt32($Flags || 0) &&
- ($fh ? $self->_SendFile($fh, $LocalPathName) :
- $self->_SendString($Data, 'd')) &&
+ $self->_SendListSize('ArgC', 3) &&
+ $self->_SendString('ServerPathName', $ServerPathName) &&
+ $self->_SendUInt32('Flags', $Flags || 0) &&
+ ($fh ? $self->_SendFile('FileData', $fh, $LocalPathName) :
+ $self->_SendString('Data', $Data, 'd')) &&
$self->_RecvList('');
}
@@ -1066,12 +1080,12 @@ sub _GetFileOrString($$$)
# Send the RPC and get the reply
my $Success = $self->_StartRPC($RPC_GETFILE) &&
- $self->_SendListSize(1) &&
- $self->_SendString($ServerPathName) &&
+ $self->_SendListSize('ArgC', 1) &&
+ $self->_SendString('ServerPathName', $ServerPathName) &&
$self->_RecvList('.');
return undef if (!$Success);
- return $self->_RecvFile($fh, $LocalPathName) if ($fh);
- return $self->_RecvString('d');
+ return $self->_RecvFile('FileData', $fh, $LocalPathName) if ($fh);
+ return $self->_RecvString('StringData', 'd');
}
sub GetFile($$$)
@@ -1109,17 +1123,19 @@ sub Run($$$;$$$)
debug("Run $self->{agenthost} '", join("' '", @$Argv), "'\n");
if (!$self->_StartRPC($RPC_RUN) or
- !$self->_SendListSize(4 + @$Argv) or
- !$self->_SendUInt32($Flags) or
- !$self->_SendString($ServerInPath || "") or
- !$self->_SendString($ServerOutPath || "") or
- !$self->_SendString($ServerErrPath || ""))
+ !$self->_SendListSize('ArgC', 4 + @$Argv) or
+ !$self->_SendUInt32('Flags', $Flags) or
+ !$self->_SendString('ServerInPath', $ServerInPath || "") or
+ !$self->_SendString('ServerOutPath', $ServerOutPath || "") or
+ !$self->_SendString('ServerErrPath', $ServerErrPath || ""))
{
return undef;
}
+ my $i = 0;
foreach my $Arg (@$Argv)
{
- return undef if (!$self->_SendString($Arg));
+ return undef if (!$self->_SendString("Cmd$i", $Arg));
+ $i++;
}
# Get the reply
@@ -1155,8 +1171,8 @@ sub Wait($$$;$)
# Send the command
if (!$self->_StartRPC($RPC_WAIT) or
- !$self->_SendListSize(1) or
- !$self->_SendUInt64($Pid))
+ !$self->_SendListSize('ArgC', 1) or
+ !$self->_SendUInt64('Pid', $Pid))
{
last;
}
@@ -1185,9 +1201,9 @@ sub Wait($$$;$)
# Send the command
if (!$self->_StartRPC($RPC_WAIT2) or
- !$self->_SendListSize(2) or
- !$self->_SendUInt64($Pid) or
- !$self->_SendUInt32($Remaining))
+ !$self->_SendListSize('ArgC', 2) or
+ !$self->_SendUInt64('Pid', $Pid) or
+ !$self->_SendUInt32('Timeout', $Remaining))
{
last;
}
@@ -1213,13 +1229,15 @@ sub Rm($@)
# Send the command
if (!$self->_StartRPC($RPC_RM) or
- !$self->_SendListSize(scalar(@_)))
+ !$self->_SendListSize('Count', scalar(@_)))
{
return $self->GetLastError();
}
+ my $i = 0;
foreach my $Filename (@_)
{
- return $self->GetLastError() if (!$self->_SendString($Filename));
+ return $self->GetLastError() if (!$self->_SendString("File$i", $Filename));
+ $i++;
}
# Get the reply
@@ -1233,9 +1251,9 @@ sub SetTime($)
# Send the command
if (!$self->_StartRPC($RPC_SETTIME) or
- !$self->_SendListSize(2) or
- !$self->_SendUInt64(time()) or
- !$self->_SendUInt32(30))
+ !$self->_SendListSize('ArgC', 2) or
+ !$self->_SendUInt64('Time', time()) or
+ !$self->_SendUInt32('Leeway', 30))
{
return undef;
}
--
1.8.5.3
More information about the wine-patches
mailing list