Put spacing around locking in util.c for clarity.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
diff --git a/util.c b/util.c
index b3cb9c0..61233a8 100644
--- a/util.c
+++ b/util.c
@@ -710,9 +710,7 @@ void tq_free(struct thread_q *tq)
static void tq_freezethaw(struct thread_q *tq, bool frozen)
{
mutex_lock(&tq->mutex);
-
tq->frozen = frozen;
-
pthread_cond_signal(&tq->cond);
mutex_unlock(&tq->mutex);
}
@@ -740,14 +738,12 @@ bool tq_push(struct thread_q *tq, void *data)
INIT_LIST_HEAD(&ent->q_node);
mutex_lock(&tq->mutex);
-
if (!tq->frozen) {
list_add_tail(&ent->q_node, &tq->q);
} else {
free(ent);
rc = false;
}
-
pthread_cond_signal(&tq->cond);
mutex_unlock(&tq->mutex);
@@ -761,7 +757,6 @@ void *tq_pop(struct thread_q *tq, const struct timespec *abstime)
int rc;
mutex_lock(&tq->mutex);
-
if (!list_empty(&tq->q))
goto pop;
@@ -773,16 +768,15 @@ void *tq_pop(struct thread_q *tq, const struct timespec *abstime)
goto out;
if (list_empty(&tq->q))
goto out;
-
pop:
ent = list_entry(tq->q.next, struct tq_ent, q_node);
rval = ent->data;
list_del(&ent->q_node);
free(ent);
-
out:
mutex_unlock(&tq->mutex);
+
return rval;
}
@@ -1441,6 +1435,7 @@ static bool setup_stratum_curl(struct pool *pool)
if (unlikely(!pool->stratum_curl))
quit(1, "Failed to curl_easy_init in initiate_stratum");
mutex_unlock(&pool->stratum_lock);
+
curl = pool->stratum_curl;
if (!pool->sockbuf) {
@@ -1517,6 +1512,7 @@ void suspend_stratum(struct pool *pool)
{
clear_sockbuf(pool);
applog(LOG_INFO, "Closing socket for stratum pool %d", pool->pool_no);
+
mutex_lock(&pool->stratum_lock);
pool->stratum_active = pool->stratum_notify = false;
if (pool->stratum_curl) {
@@ -1654,6 +1650,7 @@ out:
free(pool->nonce1);
pool->sessionid = pool->nonce1 = NULL;
cg_wunlock(&pool->data_lock);
+
applog(LOG_DEBUG, "Failed to resume stratum, trying afresh");
noresume = true;
goto resend;