From 6599e7d1a79eac768d0ea8793c0ff1a7d5af0414 Mon Sep 17 00:00:00 2001 From: pooler Date: Sat, 11 Feb 2012 00:09:50 +0100 Subject: [PATCH] Only detect the number of processors once --- cpu-miner.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/cpu-miner.c b/cpu-miner.c index f9eea2d..309f45b 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -782,24 +782,6 @@ static void parse_arg (int key, char *arg) default: show_usage_and_exit(1); } - -#if defined(WIN32) || defined(WIN64) - SYSTEM_INFO sysinfo; - GetSystemInfo(&sysinfo); - num_processors = sysinfo.dwNumberOfProcessors; -#elif defined(_SC_NPROCESSORS_ONLN) - num_processors = sysconf(_SC_NPROCESSORS_ONLN); -#elif defined(HW_NCPU) - int req[] = { CTL_HW, HW_NCPU }; - size_t len = sizeof(num_processors); - v = sysctl(req, 2, &num_processors, &len, NULL, 0); -#else - num_processors = 1; -#endif - if (num_processors < 1) - num_processors = 1; - if (!opt_n_threads) - opt_n_threads = num_processors; } static void parse_config(void) @@ -863,6 +845,24 @@ int main(int argc, char *argv[]) pthread_mutex_init(&stats_lock, NULL); pthread_mutex_init(&g_work_lock, NULL); +#if defined(WIN32) || defined(WIN64) + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + num_processors = sysinfo.dwNumberOfProcessors; +#elif defined(_SC_NPROCESSORS_ONLN) + num_processors = sysconf(_SC_NPROCESSORS_ONLN); +#elif defined(HW_NCPU) + int req[] = { CTL_HW, HW_NCPU }; + size_t len = sizeof(num_processors); + v = sysctl(req, 2, &num_processors, &len, NULL, 0); +#else + num_processors = 1; +#endif + if (num_processors < 1) + num_processors = 1; + if (!opt_n_threads) + opt_n_threads = num_processors; + if (!rpc_userpass) { if (!rpc_user || !rpc_pass) { applog(LOG_ERR, "No login credentials supplied");