From 35f4d9595cf33bda3626a3acf7612404431942d4 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 22 Jun 2004 18:51:08 +0000 Subject: [PATCH] Make sure restorefans is called only once. Suggested by James Olin Oden. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2605 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/pwm/fancontrol.pl | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/prog/pwm/fancontrol.pl b/prog/pwm/fancontrol.pl index f0b54c8e..01e6dcfc 100755 --- a/prog/pwm/fancontrol.pl +++ b/prog/pwm/fancontrol.pl @@ -65,6 +65,7 @@ our @afcmaxtemp; our @afcmintemp; our @afcminstart; our @afcminstop; +our $fanrestored; sub loadconfig($); sub pwmdisable($); @@ -298,22 +299,26 @@ sub pwmenable($) ################################################################ sub restorefans() { - $SIG{TERM} = 'IGNORE'; - $SIG{HUP} = 'IGNORE'; - $SIG{INT} = 'IGNORE'; - $SIG{QUIT} = 'IGNORE'; - - print("Aborting, restoring fans...\n"); - my $fcvcount = 0; - - while ( $fcvcount < $#afcpwm+1) + unless ($fanrestored) { - my $pwmo = $afcpwm[$fcvcount]; - &pwmdisable($afcpwm[$fcvcount]); - $fcvcount++; + $SIG{TERM} = 'IGNORE'; + $SIG{HUP} = 'IGNORE'; + $SIG{INT} = 'IGNORE'; + $SIG{QUIT} = 'IGNORE'; + + print("Aborting, restoring fans...\n"); + my $fcvcount = 0; + + while ($fcvcount < $#afcpwm+1) + { + my $pwmo = $afcpwm[$fcvcount]; + &pwmdisable($afcpwm[$fcvcount]); + $fcvcount++; + } + print("Verify fans have returned to full speed\n"); + $fanrestored = 1; + exit(0); } - print("Verify fans have returned to full speed\n"); - exit(0); }