Kaynağa Gözat

Time out faster when RAVE gets stuck waiting for the amp

Zachary Kotlarek 12 yıl önce
ebeveyn
işleme
62b8f7c384
1 değiştirilmiş dosya ile 11 ekleme ve 1 silme
  1. 11 1
      dmx/rave.pl

+ 11 - 1
dmx/rave.pl

@@ -50,6 +50,8 @@ my $PULL_TIMEOUT = $PUSH_TIMEOUT * 3;
 my $DELAY        = $PULL_TIMEOUT / 2;
 my $DELAY        = $PULL_TIMEOUT / 2;
 my $AMP_DELAY    = 6;
 my $AMP_DELAY    = 6;
 my $AMP_BOOTING  = 0;
 my $AMP_BOOTING  = 0;
+my $AMP_START    = undef();
+my $AMP_TIMEOUT  = $PUSH_TIMEOUT;
 
 
 # Debug
 # Debug
 my $DEBUG = 0;
 my $DEBUG = 0;
@@ -219,6 +221,13 @@ sub ampWait($$$) {
 		print STDERR "ampWait()\n";
 		print STDERR "ampWait()\n";
 	}
 	}
 
 
+	# Ensure we don't loop forever
+	if (!defined($AMP_START)) {
+		$AMP_START = Time::HiRes::time();
+	} elsif (Time::HiRes::time() - $AMP_START > $AMP_TIMEOUT) {
+		die("Timeout waiting for amp to start\n");
+	}
+
 	# Just loop until the amp is up, then set a new "next" handler
 	# Just loop until the amp is up, then set a new "next" handler
 	if ($exists{'AMPLIFIER'}) {
 	if ($exists{'AMPLIFIER'}) {
 		if ($DEBUG) {
 		if ($DEBUG) {
@@ -250,8 +259,9 @@ sub ampWait($$$) {
 			sleep($AMP_DELAY);
 			sleep($AMP_DELAY);
 		}
 		}
 
 
-		# Reset the amp boot delay, now that it's running
+		# Reset the amp boot delay and amp start time now that it's running
 		$AMP_BOOTING = 0;
 		$AMP_BOOTING = 0;
+		undef($AMP_START);
 	} else {
 	} else {
 
 
 		# The amp wasn't up when we checked, so it will need a boot delay
 		# The amp wasn't up when we checked, so it will need a boot delay