From c68b30c08edcfd463504c79d0b90e4362d2e3b83 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 22 Jan 2015 17:07:01 +1100 Subject: [PATCH] Grab the caller of dec_instance_ref for debugging --- src/stratifier.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 927d7374..d837df18 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1104,25 +1104,19 @@ static stratum_instance_t *ref_instance_by_id(sdata_t *sdata, int64_t id) } /* Decrease the reference count of instance. */ -static void ___dec_instance_ref(stratum_instance_t *instance, const char *file, const char *func, - const int line) +static void _dec_instance_ref(sdata_t *sdata, stratum_instance_t *instance, const char *file, + const char *func, const int line) { - instance->ref--; - if (unlikely(instance->ref < 0)) { + ck_wlock(&sdata->instance_lock); + if (unlikely(--instance->ref < 0)) { LOGERR("Instance ref count dropped below zero from %s %s:%d", file, func, line); instance->ref = 0; } -} - -#define __dec_instance_ref(instance) ___dec_instance_ref(instance, __FILE__, __func__, __LINE__) - -static void dec_instance_ref(sdata_t *sdata, stratum_instance_t *instance) -{ - ck_wlock(&sdata->instance_lock); - __dec_instance_ref(instance); ck_wunlock(&sdata->instance_lock); } +#define dec_instance_ref(sdata, instance) _dec_instance_ref(sdata, instance, __FILE__, __func__, __LINE__) + /* Enter with write instance_lock held */ static stratum_instance_t *__stratum_add_instance(ckpool_t *ckp, int64_t id, int server) {