mbpfan-josie

Change default polling_interval to 1

This allows mbpfan to react more quickly to changing workloads and
avoid CPU throttling.  Also change unit test expectations.
Fixes #159.

dd2c305593e43778f072f48e3f6331ba151548c9
Andrew Gaul <andrew@gaul.org> · 2019-01-18T11:32 · browse files at this commit

parents: 50f3a67

diff --git a/mbpfan.conf b/mbpfan.conf
index e65129b..39d4b57 100644
--- a/mbpfan.conf
+++ b/mbpfan.conf
@@ -15,4 +15,4 @@
 low_temp = 63			# try ranges 55-63, default is 63
 high_temp = 66			# try ranges 58-66, default is 66
 max_temp = 86			# take highest number returned by "cat /sys/devices/platform/coretemp.*/hwmon/hwmon*/temp*_max", divide by 1000
-polling_interval = 7	# default is 7 seconds
+polling_interval = 1	# default is 1 seconds
diff --git a/mbpfan.conf.test0 b/mbpfan.conf.test0
index 13bccf6..5095078 100644
--- a/mbpfan.conf.test0
+++ b/mbpfan.conf.test0
@@ -5,4 +5,4 @@ max_fan1_speed = 6200	# put the *highest* value of "cat /sys/devices/platform/ap
 low_temp = 63			# try ranges 55-63, default is 63
 high_temp = 66			# try ranges 58-66, default is 66
 max_temp = 86			# take highest number returned by "cat /sys/devices/platform/coretemp.*/hwmon/hwmon*/temp*_max", divide by 1000
-polling_interval = 7	# default is 7 seconds
+polling_interval = 7	# default is 1 second
diff --git a/mbpfan.conf.test1 b/mbpfan.conf.test1
index 8a18c95..bea4137 100644
--- a/mbpfan.conf.test1
+++ b/mbpfan.conf.test1
@@ -4,4 +4,4 @@ max_fan1_speed = 6200	# default is 6200
 low_temp = 63			# try ranges 55-63, default is 63
 high_temp = 66			# try ranges 58-66, default is 66
 max_temp = 86			# do not set it > 90, default is 86
-polling_interval = 1	# default is 7
+polling_interval = 2	# default is 1 second
diff --git a/mbpfan.conf.test2 b/mbpfan.conf.test2
index 9451ef8..90b5537 100644
--- a/mbpfan.conf.test2
+++ b/mbpfan.conf.test2
@@ -4,4 +4,4 @@ min_fan2_speed = 2000	# default is 6200
 low_temp = 63			# try ranges 55-63, default is 63
 high_temp = 66			# try ranges 58-66, default is 66
 max_temp = 86			# do not set it > 90, default is 86
-polling_interval = 1	# default is 7
+polling_interval = 1	# default is 1 second
diff --git a/src/mbpfan.c b/src/mbpfan.c
index f183229..0afe2a4 100644
--- a/src/mbpfan.c
+++ b/src/mbpfan.c
@@ -63,7 +63,7 @@ int max_temp = 86;   // do not set it > 90
 #define NUM_MIN_FAN_SPEED_DEFAULT 2000
 #define NUM_MAX_FAN_SPEED_DEFAULT 6200
 
-int polling_interval = 7;
+int polling_interval = 1;
 
 t_sensors* sensors = NULL;
 t_fans* fans = NULL;
diff --git a/src/minunit.c b/src/minunit.c
index 7389e1f..2818b50 100644
--- a/src/minunit.c
+++ b/src/minunit.c
@@ -136,7 +136,7 @@ static const char *test_settings()
 
     retrieve_settings("./mbpfan.conf.test1", fan);
     mu_assert("max_fan_speed value is not 6200", fan->fan_max_speed == 6200);
-    mu_assert("polling_interval is not 1", polling_interval == 1);
+    mu_assert("polling_interval is not 2", polling_interval == 2);
 
     fan->fan_min_speed = -1;
     retrieve_settings("./mbpfan.conf.test0", fan);
@@ -200,10 +200,10 @@ static const char *test_settings_reload()
     retrieve_settings("./mbpfan.conf", fan);
     printf("Testing the _supplied_ mbpfan.conf (not the one you are using)..\n");
     // cannot tests min_fan_speed since it is not set and thus auto-detected
-    mu_assert("polling_interval is not 7 before SIGHUP", polling_interval == 7);
+    mu_assert("polling_interval is not 1 before SIGHUP", polling_interval == 1);
     raise(SIGHUP);
     mu_assert("min_fan_speed value is not 6200 after SIGHUP", fan->fan_min_speed == 6200);
-    mu_assert("polling_interval is not 1 after SIGHUP", polling_interval == 1);
+    mu_assert("polling_interval is not 2 after SIGHUP", polling_interval == 2);
     retrieve_settings("./mbpfan.conf", fan);
     free(fan);
     return 0;