From 53c8085aa9cc2f471064799716f3ddb02d116c7e Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Mon, 11 Sep 2017 01:18:37 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consumer/speed_controller.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/consumer/speed_controller.go b/consumer/speed_controller.go index 9544fe1..d02e3db 100644 --- a/consumer/speed_controller.go +++ b/consumer/speed_controller.go @@ -48,10 +48,9 @@ func (c *fanControl) StartControl() { log.Info("Fan control started") ticker := time.Tick(c.sampleDuration) - fanSpeedList := make([]int, c.processorCount) - + pastFanSpeedList := make([]int, c.processorCount) + newFanSpeedList := make([]int, c.processorCount) for { - newFanSpeedList := make([]int, c.processorCount) checker: for { select { @@ -63,11 +62,11 @@ func (c *fanControl) StartControl() { return } } - if (!compareFanSpeed(fanSpeedList, newFanSpeedList)) { - copy(fanSpeedList, newFanSpeedList) + if (!compareFanSpeed(pastFanSpeedList, newFanSpeedList)) { + copy(pastFanSpeedList, newFanSpeedList) args := make([]string, 0) args = append(args, "raw", "0x3a", "0x01", ) - for _, item := range fanSpeedList { + for _, item := range newFanSpeedList { args = append(args, fmt.Sprintf("0x%x", item)) } args = append(args, @@ -89,6 +88,7 @@ func (c *fanControl) StartControl() { } func compareFanSpeed(old, new []int) bool { + new = new[:len(old)] // this line is the key for i, v := range old { if v != new[i] { // here is no bounds checking for b[i] return false