From cf573d03ff95daae3888f1dcae9db56976d53a1c Mon Sep 17 00:00:00 2001 From: Lauri Kasanen Date: Tue, 14 Jan 2014 18:59:24 +0200 Subject: [PATCH 1/2] Mark some variables & function static --- cpu-miner.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cpu-miner.c b/cpu-miner.c index 49f8f3d..c90391c 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -124,7 +124,7 @@ static bool opt_quiet = false; static int opt_retries = -1; static int opt_fail_pause = 30; int opt_timeout = 270; -int opt_scantime = 5; +static int opt_scantime = 5; static json_t *opt_config; static const bool opt_time = true; static enum sha256_algos opt_algo = ALGO_SCRYPT; @@ -144,11 +144,11 @@ struct work_restart *work_restart = NULL; static struct stratum_ctx stratum; pthread_mutex_t applog_lock; -pthread_mutex_t stats_lock; +static pthread_mutex_t stats_lock; static unsigned long accepted_count = 0L; static unsigned long rejected_count = 0L; -double *thr_hashrates; +static double *thr_hashrates; #ifdef HAVE_GETOPT_LONG #include @@ -1244,7 +1244,7 @@ static void parse_cmdline(int argc, char *argv[]) } #ifndef WIN32 -void signal_handler(int sig) +static void signal_handler(int sig) { switch (sig) { case SIGHUP: From c184d91d2ccf9947bd1a52482feeb3d247e0f808 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen Date: Tue, 14 Jan 2014 19:20:16 +0200 Subject: [PATCH 2/2] SCHED_IDLE and SCHED_BATCH can only be used with sched_priority 0 The function was randomly failing to drop the priority, because the field was not initialized - it was random garbage instead of 0, leading to EINVAL. --- cpu-miner.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpu-miner.c b/cpu-miner.c index c90391c..5d252ed 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -47,6 +47,7 @@ static inline void drop_policy(void) { struct sched_param param; + param.sched_priority = 0; #ifdef SCHED_IDLE if (unlikely(sched_setscheduler(0, SCHED_IDLE, ¶m) == -1))