Module: tools
Branch: master
Commit: bb7361dccc5918ae71e1ef341c7c00eaa6fb1d48
URL: http://source.winehq.org/git/tools.git/?a=commit;h=bb7361dccc5918ae71e1ef34…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Mon Feb 25 17:32:50 2013 +0100
testbot/TestAgent: Retrieve the netcat error when the connection breaks.
It may provide important clues as to what went wrong, especially when trying to connect.
---
testbot/lib/WineTestBot/TestAgent.pm | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/testbot/lib/WineTestBot/TestAgent.pm b/testbot/lib/WineTestBot/TestAgent.pm
index 4fe1b25..cda83a8 100644
--- a/testbot/lib/WineTestBot/TestAgent.pm
+++ b/testbot/lib/WineTestBot/TestAgent.pm
@@ -88,6 +88,7 @@ sub Disconnect($)
# which will avoid undue delays.
$self->{ssh}->disconnect();
$self->{ssh} = undef;
+ $self->{nc} = undef;
}
if ($self->{sshfd})
{
@@ -148,7 +149,29 @@ sub _SetError($$$)
$self->{err} = $Msg;
# And disconnect on fatal errors since the connection is unusable anyway
- $self->Disconnect() if ($Level == $FATAL);
+ if ($Level == $FATAL)
+ {
+ if ($self->{ssh})
+ {
+ # Try to capture the netcat exit code and error message as
+ # they may provide important clues as to what went wrong
+ my $rc = $self->{fd}->exit_status();
+ if ($rc)
+ {
+ my $ncerr;
+ eval
+ {
+ alarm(2);
+ $self->{fd}->read($ncerr, 1024, 1);
+ alarm(0);
+ };
+ $ncerr = $rc if (!$ncerr);
+ $ncerr = "the \"$self->{nc}\" command returned $ncerr";
+ $self->{err} = $self->{agentversion} ? "$self->{err}\n$ncerr" : $ncerr;
+ }
+ }
+ $self->Disconnect();
+ }
}
elsif (!$self->{err})
{
@@ -851,7 +874,9 @@ sub _Connect($)
# Use netcat to forward the connection from the SSH server to the TestAgent
# server. Note that we won't know about netcat errors at this point.
- if (!$self->{fd}->exec("nc -q0 '$self->{agenthost}' '$self->{agentport}'"))
+ $self->{nc} = "nc -q0 '$self->{agenthost}' '$self->{agentport}'";
+ debug("Tunneling command: $self->{nc}\n");
+ if (!$self->{fd}->exec($self->{nc}))
{
$self->_SetError($FATAL, "Unable to start netcat: " . $self->_ssherror());
return undef;
@@ -864,7 +889,7 @@ sub _Connect($)
if (!defined $self->{agentversion})
{
# We have already been disconnected at this point
- $self->{err} = "Unable to get the protocol version spoken by the server: $self->{err}";
+ debug("could not get the protocol version spoken by the server\n");
return undef;
}
Module: tools
Branch: master
Commit: 3fff4c25a586c150969ea181519228e5855dec07
URL: http://source.winehq.org/git/tools.git/?a=commit;h=3fff4c25a586c150969ea181…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Mon Feb 25 17:32:11 2013 +0100
testbot/TestAgent: 'nc -q0' seems to be the default but make it explicit just in case.
---
testbot/lib/WineTestBot/TestAgent.pm | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/testbot/lib/WineTestBot/TestAgent.pm b/testbot/lib/WineTestBot/TestAgent.pm
index 7852e41..4fe1b25 100644
--- a/testbot/lib/WineTestBot/TestAgent.pm
+++ b/testbot/lib/WineTestBot/TestAgent.pm
@@ -851,7 +851,7 @@ sub _Connect($)
# Use netcat to forward the connection from the SSH server to the TestAgent
# server. Note that we won't know about netcat errors at this point.
- if (!$self->{fd}->exec("nc '$self->{agenthost}' '$self->{agentport}'"))
+ if (!$self->{fd}->exec("nc -q0 '$self->{agenthost}' '$self->{agentport}'"))
{
$self->_SetError($FATAL, "Unable to start netcat: " . $self->_ssherror());
return undef;
Module: tools
Branch: master
Commit: da4926a61e72a4a91e1941a53872828a9d725ea7
URL: http://source.winehq.org/git/tools.git/?a=commit;h=da4926a61e72a4a91e1941a5…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Mon Feb 25 16:59:57 2013 +0100
testbot/testagentd: Catch SIGPIPE so the server does not die if the client disconnects during a file transfer.
---
testbot/src/testagentd/platform_unix.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/testbot/src/testagentd/platform_unix.c b/testbot/src/testagentd/platform_unix.c
index d7d8f54..cd08c58 100644
--- a/testbot/src/testagentd/platform_unix.c
+++ b/testbot/src/testagentd/platform_unix.c
@@ -228,6 +228,8 @@ void ta_freeaddrinfo(struct addrinfo *addresses)
int platform_init(void)
{
struct sigaction sa, osa;
+
+ /* Catch SIGCHLD so we can keep track of child processes */
sa.sa_handler = reaper;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
@@ -236,5 +238,18 @@ int platform_init(void)
error("could not set up the SIGCHLD handler: %s\n", strerror(errno));
return 0;
}
+
+ /* Catch SIGPIPE so we don't die if the client disconnects at an
+ * inconvenient time
+ */
+ sa.sa_handler = SIG_IGN;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_RESTART;
+ if (sigaction(SIGPIPE, &sa, &osa) < 0)
+ {
+ error("could not set up the SIGPIPE handler: %s\n", strerror(errno));
+ return 0;
+ }
+
return 1;
}