From 3a0cc43ac89ae8f778764c9f5e27b361e4986913 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 10 May 2013 02:38:05 +0200 Subject: [PATCH] build-remote.pl: Properly close the SSH connection between attempts --- perl/lib/Nix/SSH.pm | 1 + scripts/build-remote.pl.in | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/perl/lib/Nix/SSH.pm b/perl/lib/Nix/SSH.pm index 68f4a628b..584c44500 100644 --- a/perl/lib/Nix/SSH.pm +++ b/perl/lib/Nix/SSH.pm @@ -44,6 +44,7 @@ sub closeSSHConnection { if ($sshStarted) { system("ssh $sshHost @sshOpts -O exit 2> /dev/null") == 0 or warn "unable to stop SSH master: $?"; + $sshStarted = 0; } } diff --git a/scripts/build-remote.pl.in b/scripts/build-remote.pl.in index dcd863003..00d7cd8b4 100755 --- a/scripts/build-remote.pl.in +++ b/scripts/build-remote.pl.in @@ -195,9 +195,10 @@ REQ: while (1) { # Connect to the selected machine. @sshOpts = ("-i", $machine->{sshKeys}, "-x"); $hostName = $machine->{hostName}; - last REQ if - openSSHConnection($hostName) && - system("ssh $hostName @sshOpts nix-builds-inhibited < /dev/null > /dev/null 2>&1") != 0; + if (openSSHConnection($hostName)) { + last REQ if system("ssh $hostName @sshOpts nix-builds-inhibited < /dev/null > /dev/null 2>&1") != 0; + closeSSHConnection; + } warn "unable to open SSH connection to $hostName, trying other available machines...\n"; $machine->{enabled} = 0;