Commit 60a40a3c authored by Leigh B Stoller's avatar Leigh B Stoller

Wrap in a timeout so that a hung serial controller will not wedge

swap.
parent 22f04bc1
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2000-2002, 2005, 2006 University of Utah and the Flux Group. # Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
...@@ -116,7 +116,31 @@ sub rpc27ctrl { ...@@ -116,7 +116,31 @@ sub rpc27ctrl {
if ($debug) { if ($debug) {
print "outlet_strings: ", join(" ",map("($_)",@outlet_strings)), "\n"; print "outlet_strings: ", join(" ",map("($_)",@outlet_strings)), "\n";
} }
#
# Run the rest in a child process, protected by an alarm to ensure that
# we are not hung up forever if the controller is in some funky state.
#
my $syspid = fork();
if ($syspid) {
local $SIG{ALRM} = sub { kill("TERM", $syspid); };
#
# Give it 30 seconds for initial connect plus time per outlet.
# Probably too long.
#
alarm 30 + (15 * scalar(@outlet_strings));
waitpid($syspid, 0);
alarm 0;
my $exitstatus = $?;
if ($exitstatus == 15) {
print STDERR "*** power: $controller is wedged.\n";
}
return($exitstatus);
}
TBdbfork();
# #
# Form the connection to the controller via a "tip" line to the # Form the connection to the controller via a "tip" line to the
# capture process. Once we have that, we can just talk to the # capture process. Once we have that, we can just talk to the
...@@ -124,7 +148,7 @@ sub rpc27ctrl { ...@@ -124,7 +148,7 @@ sub rpc27ctrl {
# #
if (! ($TIP = tipconnect($controller))) { if (! ($TIP = tipconnect($controller))) {
print STDERR "*** Could not form TIP connection to $controller\n"; print STDERR "*** Could not form TIP connection to $controller\n";
return 1; exit(1);
} }
foreach my $outlet (@outlet_strings) { foreach my $outlet (@outlet_strings) {
...@@ -174,13 +198,11 @@ sub rpc27ctrl { ...@@ -174,13 +198,11 @@ sub rpc27ctrl {
} }
if ($status) { if ($status) {
close($TIP); close($TIP);
return 1; exit(1);
} }
} }
close($TIP); close($TIP);
return 0; exit(0);
} }
# #
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment