From e4476a5eeece606aab32193d7d662943fb7d7ec6 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Fri, 6 Nov 2015 19:19:47 +0100 Subject: [PATCH] reduce crashes on debug tests --- api.cpp | 9 ++++----- ccminer.cpp | 13 ++++++------- cuda.cpp | 2 ++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/api.cpp b/api.cpp index 86e2b4f..337a518 100644 --- a/api.cpp +++ b/api.cpp @@ -995,7 +995,7 @@ void *api_thread(void *userdata) /* to be able to report the default value set in each algo */ void api_set_throughput(int thr_id, uint32_t throughput) { - if (thr_id < MAX_GPUS) { + if (thr_id < MAX_GPUS && thr_info) { struct cgpu_info *cgpu = &thr_info[thr_id].gpu; uint32_t ws = throughput; uint8_t i = 0; @@ -1007,9 +1007,8 @@ void api_set_throughput(int thr_id, uint32_t throughput) if (i && (1U << i) < throughput) { cgpu->intensity += ((float) (throughput-(1U << i)) / (1U << i)); } - - // to display in bench results - if (opt_benchmark) - bench_set_throughput(thr_id, throughput); } + // to display in bench results + if (opt_benchmark) + bench_set_throughput(thr_id, throughput); } diff --git a/ccminer.cpp b/ccminer.cpp index 62ef352..ab52139 100644 --- a/ccminer.cpp +++ b/ccminer.cpp @@ -167,7 +167,7 @@ pthread_mutex_t stratum_work_lock; char *opt_cert; char *opt_proxy; long opt_proxy_type; -struct thr_info *thr_info; +struct thr_info *thr_info = NULL; static int work_thr_id; struct thr_api *thr_api; int longpoll_thr_id = -1; @@ -473,6 +473,7 @@ void get_currentalgo(char* buf, int sz) */ void proper_exit(int reason) { + restart_threads(); if (abort_flag) /* already called */ return; @@ -3042,10 +3043,13 @@ int main(int argc, char *argv[]) rpc_user = strdup(""); rpc_pass = strdup(""); rpc_url = strdup(""); - jane_params = strdup(""); pthread_mutex_init(&applog_lock, NULL); + pthread_mutex_init(&stratum_sock_lock, NULL); + pthread_mutex_init(&stratum_work_lock, NULL); + pthread_mutex_init(&stats_lock, NULL); + pthread_mutex_init(&g_work_lock, NULL); // number of cpus for thread affinity #if defined(WIN32) @@ -3114,11 +3118,6 @@ int main(int argc, char *argv[]) /* init stratum data.. */ memset(&stratum.url, 0, sizeof(stratum)); - pthread_mutex_init(&stratum_sock_lock, NULL); - pthread_mutex_init(&stratum_work_lock, NULL); - - pthread_mutex_init(&stats_lock, NULL); - pthread_mutex_init(&g_work_lock, NULL); // ensure default params are set pool_init_defaults(); diff --git a/cuda.cpp b/cuda.cpp index ffbec5b..deb58f6 100644 --- a/cuda.cpp +++ b/cuda.cpp @@ -229,6 +229,8 @@ typedef struct { double value[8]; } tsumarray; cudaError_t MyStreamSynchronize(cudaStream_t stream, int situation, int thr_id) { cudaError_t result = cudaSuccess; + if (abort_flag) + return result; if (situation >= 0) { static std::map tsum;