diff --git a/src/ckdb.c b/src/ckdb.c index ca6f1e33..24f05d4b 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -301,7 +301,7 @@ K_STORE *logqueue_store; // WORKQUEUE K_LIST *workqueue_free; K_STORE *workqueue_store; -pthread_mutex_t wq_waitlock; +mutex_t wq_waitlock; pthread_cond_t wq_waitcond; // HEARTBEATQUEUE @@ -3247,7 +3247,7 @@ static void *listener(void *arg) timeraddspec(&abs, &tsdiff); mutex_lock(&wq_waitlock); - pthread_cond_timedwait(&wq_waitcond, &wq_waitlock, &abs); + cond_timedwait(&wq_waitcond, &wq_waitlock, &abs); mutex_unlock(&wq_waitlock); } } diff --git a/src/ckdb.h b/src/ckdb.h index e8ecd940..a78ec107 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -654,7 +654,7 @@ typedef struct workqueue { extern K_LIST *workqueue_free; extern K_STORE *workqueue_store; -extern pthread_mutex_t wq_waitlock; +extern mutex_t wq_waitlock; extern pthread_cond_t wq_waitcond; // HEARTBEATQUEUE diff --git a/src/ckpool.c b/src/ckpool.c index bf9b6286..6fa34f57 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -120,7 +120,7 @@ static void *ckmsg_queue(void *arg) tv_to_ts(&abs, &now); abs.tv_sec++; if (!ckmsgq->msgs) - pthread_cond_timedwait(ckmsgq->cond, ckmsgq->lock, &abs); + cond_timedwait(ckmsgq->cond, ckmsgq->lock, &abs); msg = ckmsgq->msgs; if (msg) DL_DELETE(ckmsgq->msgs, msg); @@ -141,7 +141,7 @@ ckmsgq_t *create_ckmsgq(ckpool_t *ckp, const char *name, const void *func) strncpy(ckmsgq->name, name, 15); ckmsgq->func = func; ckmsgq->ckp = ckp; - ckmsgq->lock = ckalloc(sizeof(pthread_mutex_t)); + ckmsgq->lock = ckalloc(sizeof(mutex_t)); ckmsgq->cond = ckalloc(sizeof(pthread_cond_t)); mutex_init(ckmsgq->lock); cond_init(ckmsgq->cond); @@ -153,11 +153,11 @@ ckmsgq_t *create_ckmsgq(ckpool_t *ckp, const char *name, const void *func) ckmsgq_t *create_ckmsgqs(ckpool_t *ckp, const char *name, const void *func, const int count) { ckmsgq_t *ckmsgq = ckzalloc(sizeof(ckmsgq_t) * count); - pthread_mutex_t *lock; + mutex_t *lock; pthread_cond_t *cond; int i; - lock = ckalloc(sizeof(pthread_mutex_t)); + lock = ckalloc(sizeof(mutex_t)); cond = ckalloc(sizeof(pthread_cond_t)); mutex_init(lock); cond_init(cond); diff --git a/src/ckpool.h b/src/ckpool.h index 3f6935ae..3434e47c 100644 --- a/src/ckpool.h +++ b/src/ckpool.h @@ -33,7 +33,7 @@ struct ckmsgq { ckpool_t *ckp; char name[16]; pthread_t pth; - pthread_mutex_t *lock; + mutex_t *lock; pthread_cond_t *cond; ckmsg_t *msgs; void (*func)(ckpool_t *, void *); diff --git a/src/connector.c b/src/connector.c index 00e480b8..f567369a 100644 --- a/src/connector.c +++ b/src/connector.c @@ -95,7 +95,7 @@ struct connector_data { int64_t sends_delayed; /* For protecting the pending sends list */ - pthread_mutex_t sender_lock; + mutex_t sender_lock; pthread_cond_t sender_cond; }; @@ -470,7 +470,7 @@ void *sender(void *arg) ts_realtime(&timeout_ts); timeraddspec(&timeout_ts, &polltime); - pthread_cond_timedwait(&cdata->sender_cond, &cdata->sender_lock, &timeout_ts); + cond_timedwait(&cdata->sender_cond, &cdata->sender_lock, &timeout_ts); } sender_send = cdata->sender_sends; if (sender_send) diff --git a/src/generator.c b/src/generator.c index 1fd029f1..1eb7e8fb 100644 --- a/src/generator.c +++ b/src/generator.c @@ -103,18 +103,18 @@ struct proxy_instance { bool reconnect; /* We need to drop and reconnect */ bool alive; - pthread_mutex_t notify_lock; + mutex_t notify_lock; notify_instance_t *notify_instances; notify_instance_t *current_notify; pthread_t pth_precv; pthread_t pth_psend; - pthread_mutex_t psend_lock; + mutex_t psend_lock; pthread_cond_t psend_cond; stratum_msg_t *psends; - pthread_mutex_t share_lock; + mutex_t share_lock; share_msg_t *shares; int64_t share_id; @@ -127,7 +127,7 @@ struct proxy_instance { /* Private data for the generator */ struct generator_data { - pthread_mutex_t lock; /* Lock protecting linked lists */ + mutex_t lock; /* Lock protecting linked lists */ proxy_instance_t *proxies; /* Hash list of all proxies */ proxy_instance_t *proxy; /* Current proxy */ int proxy_notify_id; // Globally increasing notify id @@ -1294,7 +1294,7 @@ static void *proxy_send(void *arg) mutex_lock(&proxi->psend_lock); if (!proxi->psends) - pthread_cond_wait(&proxi->psend_cond, &proxi->psend_lock); + cond_wait(&proxi->psend_cond, &proxi->psend_lock); msg = proxi->psends; if (likely(msg)) DL_DELETE(proxi->psends, msg); diff --git a/src/libckpool.c b/src/libckpool.c index 350ae09e..19fe19ed 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -114,16 +114,30 @@ bool ck_completion_timeout(void *fn, void *fnarg, int timeout) return !ret; } +int _cond_wait(pthread_cond_t *cond, mutex_t *lock, const char *file, const char *func, const int line) +{ + int ret; -/* Place holders for when we add lock debugging */ -#define GETLOCK(_lock, _file, _func, _line) -#define GOTLOCK(_lock, _file, _func, _line) -#define TRYLOCK(_lock, _file, _func, _line) -#define DIDLOCK(_ret, _lock, _file, _func, _line) -#define GUNLOCK(_lock, _file, _func, _line) -#define INITLOCK(_typ, _lock, _file, _func, _line) + ret = pthread_cond_wait(cond, &lock->mutex); + lock->file = file; + lock->func = func; + lock->line = line; + return ret; +} -int _mutex_timedlock(pthread_mutex_t *lock, int timeout, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line) +int _cond_timedwait(pthread_cond_t *cond, mutex_t *lock, const struct timespec *abstime, const char *file, const char *func, const int line) +{ + int ret; + + ret = pthread_cond_timedwait(cond, &lock->mutex, abstime); + lock->file = file; + lock->func = func; + lock->line = line; + return ret; +} + + +int _mutex_timedlock(mutex_t *lock, int timeout, const char *file, const char *func, const int line) { tv_t now; ts_t abs; @@ -133,53 +147,63 @@ int _mutex_timedlock(pthread_mutex_t *lock, int timeout, __maybe_unused const ch tv_to_ts(&abs, &now); abs.tv_sec += timeout; - TRYLOCK(lock, file, func, line); - ret = pthread_mutex_timedlock(lock, &abs); - DIDLOCK(ret, lock, file, func, line); + ret = pthread_mutex_timedlock(&lock->mutex, &abs); + if (!ret) { + lock->file = file; + lock->func = func; + lock->line = line; + } return ret; } /* Make every locking attempt warn if we're unable to get the lock for more * than 10 seconds and fail if we can't get it for longer than a minute. */ -void _mutex_lock(pthread_mutex_t *lock, const char *file, const char *func, const int line) +void _mutex_lock(mutex_t *lock, const char *file, const char *func, const int line) { int ret, retries = 0; - GETLOCK(lock, file, func, line); retry: ret = _mutex_timedlock(lock, 10, file, func, line); if (unlikely(ret)) { if (likely(ret == ETIMEDOUT)) { - LOGERR("WARNING: Prolonged mutex lock contention from %s %s:%d", file, func, line); + LOGERR("WARNING: Prolonged mutex lock contention from %s %s:%d, held by %s %s:%d", + file, func, line, lock->file, lock->func, lock->line); if (++retries < 6) goto retry; quitfrom(1, file, func, line, "FAILED TO GRAB MUTEX!"); } quitfrom(1, file, func, line, "WTF MUTEX ERROR ON LOCK!"); } - GOTLOCK(lock, file, func, line); } -void _mutex_unlock(pthread_mutex_t *lock, const char *file, const char *func, const int line) +/* Does not unset lock->file/func/line since they're only relevant when the lock is held */ +void _mutex_unlock(mutex_t *lock, const char *file, const char *func, const int line) { - if (unlikely(pthread_mutex_unlock(lock))) + if (unlikely(pthread_mutex_unlock(&lock->mutex))) quitfrom(1, file, func, line, "WTF MUTEX ERROR ON UNLOCK!"); - GUNLOCK(lock, file, func, line); } -int _mutex_trylock(pthread_mutex_t *lock, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line) +int _mutex_trylock(mutex_t *lock, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line) { int ret; - TRYLOCK(lock, file, func, line); - ret = pthread_mutex_trylock(lock); - DIDLOCK(ret, lock, file, func, line); - + ret = pthread_mutex_trylock(&lock->mutex); + if (!ret) { + lock->file = file; + lock->func = func; + lock->line = line; + } return ret; } -int _wr_timedlock(pthread_rwlock_t *lock, int timeout, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line) +void mutex_destroy(mutex_t *lock) +{ + pthread_mutex_destroy(&lock->mutex); +} + + +static int wr_timedlock(pthread_rwlock_t *lock, int timeout) { tv_t now; ts_t abs; @@ -189,41 +213,45 @@ int _wr_timedlock(pthread_rwlock_t *lock, int timeout, __maybe_unused const char tv_to_ts(&abs, &now); abs.tv_sec += timeout; - TRYLOCK(lock, file, func, line); ret = pthread_rwlock_timedwrlock(lock, &abs); - DIDLOCK(ret, lock, file, func, line); return ret; } -void _wr_lock(pthread_rwlock_t *lock, const char *file, const char *func, const int line) +void _wr_lock(rwlock_t *lock, const char *file, const char *func, const int line) { int ret, retries = 0; - GETLOCK(lock, file, func, line); retry: - ret = _wr_timedlock(lock, 10, file, func, line); + ret = wr_timedlock(&lock->rwlock, 10); if (unlikely(ret)) { if (likely(ret == ETIMEDOUT)) { - LOGERR("WARNING: Prolonged write lock contention from %s %s:%d", file, func, line); + LOGERR("WARNING: Prolonged write lock contention from %s %s:%d, held by %s %s:%d", + file, func, line, lock->file, lock->func, lock->line); if (++retries < 6) goto retry; quitfrom(1, file, func, line, "FAILED TO GRAB WRITE LOCK!"); } quitfrom(1, file, func, line, "WTF ERROR ON WRITE LOCK!"); } - GOTLOCK(lock, file, func, line); + lock->file = file; + lock->func = func; + lock->line = line; } -int _wr_trylock(pthread_rwlock_t *lock, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line) +int _wr_trylock(rwlock_t *lock, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line) { - TRYLOCK(lock, file, func, line); - int ret = pthread_rwlock_trywrlock(lock); - DIDLOCK(ret, lock, file, func, line); + int ret = pthread_rwlock_trywrlock(&lock->rwlock); + + if (!ret) { + lock->file = file; + lock->func = func; + lock->line = line; + } return ret; } -int _rd_timedlock(pthread_rwlock_t *lock, int timeout, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line) +static int rd_timedlock(pthread_rwlock_t *lock, int timeout) { tv_t now; ts_t abs; @@ -233,74 +261,60 @@ int _rd_timedlock(pthread_rwlock_t *lock, int timeout, __maybe_unused const char tv_to_ts(&abs, &now); abs.tv_sec += timeout; - TRYLOCK(lock, file, func, line); ret = pthread_rwlock_timedrdlock(lock, &abs); - DIDLOCK(ret, lock, file, func, line); return ret; } -void _rd_lock(pthread_rwlock_t *lock, const char *file, const char *func, const int line) +void _rd_lock(rwlock_t *lock, const char *file, const char *func, const int line) { int ret, retries = 0; - GETLOCK(lock, file, func, line); retry: - ret = _rd_timedlock(lock, 10, file, func, line); + ret = rd_timedlock(&lock->rwlock, 10); if (unlikely(ret)) { if (likely(ret == ETIMEDOUT)) { - LOGERR("WARNING: Prolonged read lock contention from %s %s:%d", file, func, line); + LOGERR("WARNING: Prolonged read lock contention from %s %s:%d, held by %s %s:%d", + file, func, line, lock->file, lock->func, lock->line); if (++retries < 6) goto retry; quitfrom(1, file, func, line, "FAILED TO GRAB READ LOCK!"); } quitfrom(1, file, func, line, "WTF ERROR ON READ LOCK!"); } - GOTLOCK(lock, file, func, line); + lock->file = file; + lock->func = func; + lock->line = line; } -void _rw_unlock(pthread_rwlock_t *lock, const char *file, const char *func, const int line) +void _rw_unlock(rwlock_t *lock, const char *file, const char *func, const int line) { - if (unlikely(pthread_rwlock_unlock(lock))) + if (unlikely(pthread_rwlock_unlock(&lock->rwlock))) quitfrom(1, file, func, line, "WTF RWLOCK ERROR ON UNLOCK!"); - GUNLOCK(lock, file, func, line); } -void _rd_unlock(pthread_rwlock_t *lock, const char *file, const char *func, const int line) +void _rd_unlock(rwlock_t *lock, const char *file, const char *func, const int line) { _rw_unlock(lock, file, func, line); } -void _wr_unlock(pthread_rwlock_t *lock, const char *file, const char *func, const int line) +void _wr_unlock(rwlock_t *lock, const char *file, const char *func, const int line) { _rw_unlock(lock, file, func, line); } -void _mutex_init(pthread_mutex_t *lock, const char *file, const char *func, const int line) +void _mutex_init(mutex_t *lock, const char *file, const char *func, const int line) { - if (unlikely(pthread_mutex_init(lock, NULL))) + if (unlikely(pthread_mutex_init(&lock->mutex, NULL))) quitfrom(1, file, func, line, "Failed to pthread_mutex_init"); - INITLOCK(lock, CGLOCK_MUTEX, file, func, line); -} - -void mutex_destroy(pthread_mutex_t *lock) -{ - /* Ignore return code. This only invalidates the mutex on linux but - * releases resources on windows. */ - pthread_mutex_destroy(lock); } -void _rwlock_init(pthread_rwlock_t *lock, const char *file, const char *func, const int line) +void _rwlock_init(rwlock_t *lock, const char *file, const char *func, const int line) { - if (unlikely(pthread_rwlock_init(lock, NULL))) + if (unlikely(pthread_rwlock_init(&lock->rwlock, NULL))) quitfrom(1, file, func, line, "Failed to pthread_rwlock_init"); - INITLOCK(lock, CGLOCK_RW, file, func, line); } -void rwlock_destroy(pthread_rwlock_t *lock) -{ - pthread_rwlock_destroy(lock); -} void _cond_init(pthread_cond_t *cond, const char *file, const char *func, const int line) { @@ -314,11 +328,6 @@ void _cklock_init(cklock_t *lock, const char *file, const char *func, const int _rwlock_init(&lock->rwlock, file, func, line); } -void cklock_destroy(cklock_t *lock) -{ - rwlock_destroy(&lock->rwlock); - mutex_destroy(&lock->mutex); -} /* Read lock variant of cklock. Cannot be promoted. */ void _ck_rlock(cklock_t *lock, const char *file, const char *func, const int line) @@ -386,6 +395,13 @@ void _ck_wunlock(cklock_t *lock, const char *file, const char *func, const int l _mutex_unlock(&lock->mutex, file, func, line); } +void cklock_destroy(cklock_t *lock) +{ + pthread_rwlock_destroy(&lock->rwlock.rwlock); + pthread_mutex_destroy(&lock->mutex.mutex); +} + + void _cksem_init(sem_t *sem, const char *file, const char *func, const int line) { int ret; diff --git a/src/libckpool.h b/src/libckpool.h index 870e1f0b..e21acc96 100644 --- a/src/libckpool.h +++ b/src/libckpool.h @@ -145,11 +145,13 @@ static inline void flip_80(void *dest_p, const void *src_p) dest[i] = bswap_32(src[i]); } +#define cond_wait(_cond, _lock) _cond_wait(_cond, _lock, __FILE__, __func__, __LINE__) +#define cond_timedwait(_cond, _lock, _abstime) _cond_timedwait(_cond, _lock, _abstime, __FILE__, __func__, __LINE__) +#define mutex_timedlock(_lock, _timeout) _mutex_timedlock(_lock, _timeout, __FILE__, __func__, __LINE__) #define mutex_lock(_lock) _mutex_lock(_lock, __FILE__, __func__, __LINE__) #define mutex_unlock_noyield(_lock) _mutex_unlock_noyield(_lock, __FILE__, __func__, __LINE__) #define mutex_unlock(_lock) _mutex_unlock(_lock, __FILE__, __func__, __LINE__) #define mutex_trylock(_lock) _mutex_trylock(_lock, __FILE__, __func__, __LINE__) -#define mutex_timedlock(_lock, timeout) _mutex_timedlock(_lock, timeout, __FILE__, __func__, __LINE__) #define wr_lock(_lock) _wr_lock(_lock, __FILE__, __func__, __LINE__) #define wr_trylock(_lock) _wr_trylock(_lock, __FILE__, __func__, __LINE__) #define rd_lock(_lock) _rd_lock(_lock, __FILE__, __func__, __LINE__) @@ -275,10 +277,31 @@ static const char __maybe_unused *share_errs[] = { #define SHARE_ERR(x) share_errs[((x) + 9)] -/* ck locks, a write biased variant of rwlocks */ -struct cklock { +typedef struct ckmutex mutex_t; + +struct ckmutex { pthread_mutex_t mutex; + const char *file; + const char *func; + int line; +}; + +typedef struct ckrwlock rwlock_t; + +struct ckrwlock { pthread_rwlock_t rwlock; + const char *file; + const char *func; + int line; +}; + +/* ck locks, a write biased variant of rwlocks */ +struct cklock { + mutex_t mutex; + rwlock_t rwlock; + const char *file; + const char *func; + int line; }; typedef struct cklock cklock_t; @@ -386,29 +409,28 @@ void create_pthread(pthread_t *thread, void *(*start_routine)(void *), void *arg void join_pthread(pthread_t thread); bool ck_completion_timeout(void *fn, void *fnarg, int timeout); -int _mutex_timedlock(pthread_mutex_t *lock, int timeout, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line); -void _mutex_lock(pthread_mutex_t *lock, const char *file, const char *func, const int line); -void _mutex_unlock_noyield(pthread_mutex_t *lock, const char *file, const char *func, const int line); -void _mutex_unlock(pthread_mutex_t *lock, const char *file, const char *func, const int line); -int _mutex_trylock(pthread_mutex_t *lock, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line); -int _wr_timedlock(pthread_rwlock_t *lock, int timeout, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line); -void _wr_lock(pthread_rwlock_t *lock, const char *file, const char *func, const int line); -int _wr_trylock(pthread_rwlock_t *lock, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line); -int _rd_timedlock(pthread_rwlock_t *lock, int timeout, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line); -void _rd_lock(pthread_rwlock_t *lock, const char *file, const char *func, const int line); -void _rw_unlock(pthread_rwlock_t *lock, const char *file, const char *func, const int line); -void _rd_unlock_noyield(pthread_rwlock_t *lock, const char *file, const char *func, const int line); -void _wr_unlock_noyield(pthread_rwlock_t *lock, const char *file, const char *func, const int line); -void _rd_unlock(pthread_rwlock_t *lock, const char *file, const char *func, const int line); -void _wr_unlock(pthread_rwlock_t *lock, const char *file, const char *func, const int line); -void _mutex_init(pthread_mutex_t *lock, const char *file, const char *func, const int line); -void mutex_destroy(pthread_mutex_t *lock); -void _rwlock_init(pthread_rwlock_t *lock, const char *file, const char *func, const int line); -void rwlock_destroy(pthread_rwlock_t *lock); +int _cond_wait(pthread_cond_t *cond, mutex_t *lock, const char *file, const char *func, const int line); +int _cond_timedwait(pthread_cond_t *cond, mutex_t *lock, const struct timespec *abstime, const char *file, const char *func, const int line); +int _mutex_timedlock(mutex_t *lock, int timeout, const char *file, const char *func, const int line); +void _mutex_lock(mutex_t *lock, const char *file, const char *func, const int line); +void _mutex_unlock_noyield(mutex_t *lock, const char *file, const char *func, const int line); +void _mutex_unlock(mutex_t *lock, const char *file, const char *func, const int line); +int _mutex_trylock(mutex_t *lock, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line); +void mutex_destroy(mutex_t *lock); + +void _wr_lock(rwlock_t *lock, const char *file, const char *func, const int line); +int _wr_trylock(rwlock_t *lock, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line); +void _rd_lock(rwlock_t *lock, const char *file, const char *func, const int line); +void _rw_unlock(rwlock_t *lock, const char *file, const char *func, const int line); +void _rd_unlock_noyield(rwlock_t *lock, const char *file, const char *func, const int line); +void _wr_unlock_noyield(rwlock_t *lock, const char *file, const char *func, const int line); +void _rd_unlock(rwlock_t *lock, const char *file, const char *func, const int line); +void _wr_unlock(rwlock_t *lock, const char *file, const char *func, const int line); +void _mutex_init(mutex_t *lock, const char *file, const char *func, const int line); +void _rwlock_init(rwlock_t *lock, const char *file, const char *func, const int line); void _cond_init(pthread_cond_t *cond, const char *file, const char *func, const int line); void _cklock_init(cklock_t *lock, const char *file, const char *func, const int line); -void cklock_destroy(cklock_t *lock); void _ck_rlock(cklock_t *lock, const char *file, const char *func, const int line); void _ck_ilock(cklock_t *lock, const char *file, const char *func, const int line); void _ck_uilock(cklock_t *lock, const char *file, const char *func, const int line); @@ -419,6 +441,7 @@ void _ck_dwilock(cklock_t *lock, const char *file, const char *func, const int l void _ck_dlock(cklock_t *lock, const char *file, const char *func, const int line); void _ck_runlock(cklock_t *lock, const char *file, const char *func, const int line); void _ck_wunlock(cklock_t *lock, const char *file, const char *func, const int line); +void cklock_destroy(cklock_t *lock); void _cksem_init(sem_t *sem, const char *file, const char *func, const int line); void _cksem_post(sem_t *sem, const char *file, const char *func, const int line); diff --git a/src/stratifier.c b/src/stratifier.c index bf819694..0281adb7 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -308,10 +308,10 @@ struct stratifier_data { pool_stats_t stats; /* Protects changes to pool stats */ - pthread_mutex_t stats_lock; + mutex_t stats_lock; /* Serialises sends/receives to ckdb if possible */ - pthread_mutex_t ckdb_lock; + mutex_t ckdb_lock; bool ckdb_offline; @@ -359,14 +359,14 @@ struct stratifier_data { cklock_t instance_lock; share_t *shares; - pthread_mutex_t share_lock; + mutex_t share_lock; int64_t shares_generated; /* Linked list of block solves, added to during submission, removed on * accept/reject. It is likely we only ever have one solve on here but * you never know... */ - pthread_mutex_t block_lock; + mutex_t block_lock; ckmsg_t *block_solves; /* Generator message priority */ @@ -374,7 +374,7 @@ struct stratifier_data { proxy_t *proxy; /* Current proxy in use */ proxy_t *proxies; /* Hashlist of all proxies */ - pthread_mutex_t proxy_lock; /* Protects all proxy data */ + mutex_t proxy_lock; /* Protects all proxy data */ }; typedef struct stratifier_data sdata_t; @@ -3826,7 +3826,7 @@ static void parse_ckdb_cmd(ckpool_t *ckp, const char *cmd) } /* Test a value under lock and set it, returning the original value */ -static bool test_and_set(bool *val, pthread_mutex_t *lock) +static bool test_and_set(bool *val, mutex_t *lock) { bool ret; @@ -3838,7 +3838,7 @@ static bool test_and_set(bool *val, pthread_mutex_t *lock) return ret; } -static bool test_and_clear(bool *val, pthread_mutex_t *lock) +static bool test_and_clear(bool *val, mutex_t *lock) { bool ret;