From cff66e6a29d700188f6ecebeaacc8bcaa1fc1095 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Mon, 9 Apr 2018 15:44:46 +0200 Subject: [PATCH 1/2] util: Pass pthread_self() to pthread_setschedparam instead of 0 Nowhere in the man page of `pthread_setschedparam` it is mentioned that `0` is a valid value. The example uses `pthread_self()`, so should we. (noticed by Anthony Towns) --- src/util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index 393cc413d..3043f6b9a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1065,7 +1065,7 @@ int ScheduleBatchPriority(void) { #ifdef SCHED_BATCH const static sched_param param{.sched_priority = 0}; - if (int ret = pthread_setschedparam(0, SCHED_BATCH, ¶m)) { + if (int ret = pthread_setschedparam(pthread_self(), SCHED_BATCH, ¶m)) { LogPrintf("Failed to pthread_setschedparam: %s\n", strerror(errno)); return ret; } From b86730a4d74471378fbafb2bac9839110f520b76 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Mon, 9 Apr 2018 17:02:19 +0200 Subject: [PATCH 2/2] util: Remove designator initializer from ScheduleBatchPriority Although no compiler appears to complain about it, these are not valid for c++11. (http://en.cppreference.com/w/cpp/language/aggregate_initialization says they're c++20) The structure is defined as: struct sched_param { int sched_priority; }; So passing 0 for the first field has the same effect. --- src/util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index 3043f6b9a..f55c9c8c3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1064,7 +1064,7 @@ fs::path AbsPathForConfigVal(const fs::path& path, bool net_specific) int ScheduleBatchPriority(void) { #ifdef SCHED_BATCH - const static sched_param param{.sched_priority = 0}; + const static sched_param param{0}; if (int ret = pthread_setschedparam(pthread_self(), SCHED_BATCH, ¶m)) { LogPrintf("Failed to pthread_setschedparam: %s\n", strerror(errno)); return ret;