Browse Source

Merge branch 'master' into proxydev

Conflicts:
	src/generator.c
master
Con Kolivas 10 years ago
parent
commit
b80d8d6cea
  1. 4
      src/ckdb.c
  2. 2
      src/ckdb.h
  3. 8
      src/ckpool.c
  4. 2
      src/ckpool.h
  5. 4
      src/connector.c
  6. 10
      src/generator.c
  7. 156
      src/libckpool.c
  8. 69
      src/libckpool.h
  9. 14
      src/stratifier.c

4
src/ckdb.c

@ -301,7 +301,7 @@ K_STORE *logqueue_store;
// WORKQUEUE // WORKQUEUE
K_LIST *workqueue_free; K_LIST *workqueue_free;
K_STORE *workqueue_store; K_STORE *workqueue_store;
pthread_mutex_t wq_waitlock; mutex_t wq_waitlock;
pthread_cond_t wq_waitcond; pthread_cond_t wq_waitcond;
// HEARTBEATQUEUE // HEARTBEATQUEUE
@ -3247,7 +3247,7 @@ static void *listener(void *arg)
timeraddspec(&abs, &tsdiff); timeraddspec(&abs, &tsdiff);
mutex_lock(&wq_waitlock); mutex_lock(&wq_waitlock);
pthread_cond_timedwait(&wq_waitcond, &wq_waitlock, &abs); cond_timedwait(&wq_waitcond, &wq_waitlock, &abs);
mutex_unlock(&wq_waitlock); mutex_unlock(&wq_waitlock);
} }
} }

2
src/ckdb.h

@ -654,7 +654,7 @@ typedef struct workqueue {
extern K_LIST *workqueue_free; extern K_LIST *workqueue_free;
extern K_STORE *workqueue_store; extern K_STORE *workqueue_store;
extern pthread_mutex_t wq_waitlock; extern mutex_t wq_waitlock;
extern pthread_cond_t wq_waitcond; extern pthread_cond_t wq_waitcond;
// HEARTBEATQUEUE // HEARTBEATQUEUE

8
src/ckpool.c

@ -120,7 +120,7 @@ static void *ckmsg_queue(void *arg)
tv_to_ts(&abs, &now); tv_to_ts(&abs, &now);
abs.tv_sec++; abs.tv_sec++;
if (!ckmsgq->msgs) if (!ckmsgq->msgs)
pthread_cond_timedwait(ckmsgq->cond, ckmsgq->lock, &abs); cond_timedwait(ckmsgq->cond, ckmsgq->lock, &abs);
msg = ckmsgq->msgs; msg = ckmsgq->msgs;
if (msg) if (msg)
DL_DELETE(ckmsgq->msgs, 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); strncpy(ckmsgq->name, name, 15);
ckmsgq->func = func; ckmsgq->func = func;
ckmsgq->ckp = ckp; ckmsgq->ckp = ckp;
ckmsgq->lock = ckalloc(sizeof(pthread_mutex_t)); ckmsgq->lock = ckalloc(sizeof(mutex_t));
ckmsgq->cond = ckalloc(sizeof(pthread_cond_t)); ckmsgq->cond = ckalloc(sizeof(pthread_cond_t));
mutex_init(ckmsgq->lock); mutex_init(ckmsgq->lock);
cond_init(ckmsgq->cond); 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 *create_ckmsgqs(ckpool_t *ckp, const char *name, const void *func, const int count)
{ {
ckmsgq_t *ckmsgq = ckzalloc(sizeof(ckmsgq_t) * count); ckmsgq_t *ckmsgq = ckzalloc(sizeof(ckmsgq_t) * count);
pthread_mutex_t *lock; mutex_t *lock;
pthread_cond_t *cond; pthread_cond_t *cond;
int i; int i;
lock = ckalloc(sizeof(pthread_mutex_t)); lock = ckalloc(sizeof(mutex_t));
cond = ckalloc(sizeof(pthread_cond_t)); cond = ckalloc(sizeof(pthread_cond_t));
mutex_init(lock); mutex_init(lock);
cond_init(cond); cond_init(cond);

2
src/ckpool.h

@ -33,7 +33,7 @@ struct ckmsgq {
ckpool_t *ckp; ckpool_t *ckp;
char name[16]; char name[16];
pthread_t pth; pthread_t pth;
pthread_mutex_t *lock; mutex_t *lock;
pthread_cond_t *cond; pthread_cond_t *cond;
ckmsg_t *msgs; ckmsg_t *msgs;
void (*func)(ckpool_t *, void *); void (*func)(ckpool_t *, void *);

4
src/connector.c

@ -95,7 +95,7 @@ struct connector_data {
int64_t sends_delayed; int64_t sends_delayed;
/* For protecting the pending sends list */ /* For protecting the pending sends list */
pthread_mutex_t sender_lock; mutex_t sender_lock;
pthread_cond_t sender_cond; pthread_cond_t sender_cond;
}; };
@ -470,7 +470,7 @@ void *sender(void *arg)
ts_realtime(&timeout_ts); ts_realtime(&timeout_ts);
timeraddspec(&timeout_ts, &polltime); 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; sender_send = cdata->sender_sends;
if (sender_send) if (sender_send)

10
src/generator.c

@ -103,18 +103,18 @@ struct proxy_instance {
bool reconnect; /* We need to drop and reconnect */ bool reconnect; /* We need to drop and reconnect */
bool alive; bool alive;
pthread_mutex_t notify_lock; mutex_t notify_lock;
notify_instance_t *notify_instances; notify_instance_t *notify_instances;
notify_instance_t *current_notify; notify_instance_t *current_notify;
pthread_t pth_precv; pthread_t pth_precv;
pthread_t pth_psend; pthread_t pth_psend;
pthread_mutex_t psend_lock; mutex_t psend_lock;
pthread_cond_t psend_cond; pthread_cond_t psend_cond;
stratum_msg_t *psends; stratum_msg_t *psends;
pthread_mutex_t share_lock; mutex_t share_lock;
share_msg_t *shares; share_msg_t *shares;
int64_t share_id; int64_t share_id;
@ -127,7 +127,7 @@ struct proxy_instance {
/* Private data for the generator */ /* Private data for the generator */
struct generator_data { 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 *proxies; /* Hash list of all proxies */
proxy_instance_t *proxy; /* Current proxy */ proxy_instance_t *proxy; /* Current proxy */
int proxy_notify_id; // Globally increasing notify id int proxy_notify_id; // Globally increasing notify id
@ -1294,7 +1294,7 @@ static void *proxy_send(void *arg)
mutex_lock(&proxi->psend_lock); mutex_lock(&proxi->psend_lock);
if (!proxi->psends) if (!proxi->psends)
pthread_cond_wait(&proxi->psend_cond, &proxi->psend_lock); cond_wait(&proxi->psend_cond, &proxi->psend_lock);
msg = proxi->psends; msg = proxi->psends;
if (likely(msg)) if (likely(msg))
DL_DELETE(proxi->psends, msg); DL_DELETE(proxi->psends, msg);

156
src/libckpool.c

@ -114,16 +114,30 @@ bool ck_completion_timeout(void *fn, void *fnarg, int timeout)
return !ret; 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 */ ret = pthread_cond_wait(cond, &lock->mutex);
#define GETLOCK(_lock, _file, _func, _line) lock->file = file;
#define GOTLOCK(_lock, _file, _func, _line) lock->func = func;
#define TRYLOCK(_lock, _file, _func, _line) lock->line = line;
#define DIDLOCK(_ret, _lock, _file, _func, _line) return ret;
#define GUNLOCK(_lock, _file, _func, _line) }
#define INITLOCK(_typ, _lock, _file, _func, _line)
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; tv_t now;
ts_t abs; 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); tv_to_ts(&abs, &now);
abs.tv_sec += timeout; abs.tv_sec += timeout;
TRYLOCK(lock, file, func, line); ret = pthread_mutex_timedlock(&lock->mutex, &abs);
ret = pthread_mutex_timedlock(lock, &abs); if (!ret) {
DIDLOCK(ret, lock, file, func, line); lock->file = file;
lock->func = func;
lock->line = line;
}
return ret; return ret;
} }
/* Make every locking attempt warn if we're unable to get the lock for more /* 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. */ * 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; int ret, retries = 0;
GETLOCK(lock, file, func, line);
retry: retry:
ret = _mutex_timedlock(lock, 10, file, func, line); ret = _mutex_timedlock(lock, 10, file, func, line);
if (unlikely(ret)) { if (unlikely(ret)) {
if (likely(ret == ETIMEDOUT)) { 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) if (++retries < 6)
goto retry; goto retry;
quitfrom(1, file, func, line, "FAILED TO GRAB MUTEX!"); quitfrom(1, file, func, line, "FAILED TO GRAB MUTEX!");
} }
quitfrom(1, file, func, line, "WTF MUTEX ERROR ON LOCK!"); 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!"); 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; int ret;
TRYLOCK(lock, file, func, line); ret = pthread_mutex_trylock(&lock->mutex);
ret = pthread_mutex_trylock(lock); if (!ret) {
DIDLOCK(ret, lock, file, func, line); lock->file = file;
lock->func = func;
lock->line = line;
}
return ret; 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; tv_t now;
ts_t abs; 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); tv_to_ts(&abs, &now);
abs.tv_sec += timeout; abs.tv_sec += timeout;
TRYLOCK(lock, file, func, line);
ret = pthread_rwlock_timedwrlock(lock, &abs); ret = pthread_rwlock_timedwrlock(lock, &abs);
DIDLOCK(ret, lock, file, func, line);
return ret; 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; int ret, retries = 0;
GETLOCK(lock, file, func, line);
retry: retry:
ret = _wr_timedlock(lock, 10, file, func, line); ret = wr_timedlock(&lock->rwlock, 10);
if (unlikely(ret)) { if (unlikely(ret)) {
if (likely(ret == ETIMEDOUT)) { 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) if (++retries < 6)
goto retry; goto retry;
quitfrom(1, file, func, line, "FAILED TO GRAB WRITE LOCK!"); quitfrom(1, file, func, line, "FAILED TO GRAB WRITE LOCK!");
} }
quitfrom(1, file, func, line, "WTF ERROR ON 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->rwlock);
int ret = pthread_rwlock_trywrlock(lock);
DIDLOCK(ret, lock, file, func, line); if (!ret) {
lock->file = file;
lock->func = func;
lock->line = line;
}
return ret; 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; tv_t now;
ts_t abs; 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); tv_to_ts(&abs, &now);
abs.tv_sec += timeout; abs.tv_sec += timeout;
TRYLOCK(lock, file, func, line);
ret = pthread_rwlock_timedrdlock(lock, &abs); ret = pthread_rwlock_timedrdlock(lock, &abs);
DIDLOCK(ret, lock, file, func, line);
return ret; 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; int ret, retries = 0;
GETLOCK(lock, file, func, line);
retry: retry:
ret = _rd_timedlock(lock, 10, file, func, line); ret = rd_timedlock(&lock->rwlock, 10);
if (unlikely(ret)) { if (unlikely(ret)) {
if (likely(ret == ETIMEDOUT)) { 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) if (++retries < 6)
goto retry; goto retry;
quitfrom(1, file, func, line, "FAILED TO GRAB READ LOCK!"); quitfrom(1, file, func, line, "FAILED TO GRAB READ LOCK!");
} }
quitfrom(1, file, func, line, "WTF ERROR ON 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!"); 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); _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); _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"); 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"); 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) 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); _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. */ /* Read lock variant of cklock. Cannot be promoted. */
void _ck_rlock(cklock_t *lock, const char *file, const char *func, const int line) 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); _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) void _cksem_init(sem_t *sem, const char *file, const char *func, const int line)
{ {
int ret; int ret;

69
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]); 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_lock(_lock) _mutex_lock(_lock, __FILE__, __func__, __LINE__)
#define mutex_unlock_noyield(_lock) _mutex_unlock_noyield(_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_unlock(_lock) _mutex_unlock(_lock, __FILE__, __func__, __LINE__)
#define mutex_trylock(_lock) _mutex_trylock(_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_lock(_lock) _wr_lock(_lock, __FILE__, __func__, __LINE__)
#define wr_trylock(_lock) _wr_trylock(_lock, __FILE__, __func__, __LINE__) #define wr_trylock(_lock) _wr_trylock(_lock, __FILE__, __func__, __LINE__)
#define rd_lock(_lock) _rd_lock(_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)] #define SHARE_ERR(x) share_errs[((x) + 9)]
/* ck locks, a write biased variant of rwlocks */ typedef struct ckmutex mutex_t;
struct cklock {
struct ckmutex {
pthread_mutex_t mutex; pthread_mutex_t mutex;
const char *file;
const char *func;
int line;
};
typedef struct ckrwlock rwlock_t;
struct ckrwlock {
pthread_rwlock_t rwlock; 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; 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); void join_pthread(pthread_t thread);
bool ck_completion_timeout(void *fn, void *fnarg, int timeout); 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); int _cond_wait(pthread_cond_t *cond, mutex_t *lock, const char *file, const char *func, const int line);
void _mutex_lock(pthread_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);
void _mutex_unlock_noyield(pthread_mutex_t *lock, 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_unlock(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 _mutex_trylock(pthread_mutex_t *lock, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line); void _mutex_unlock_noyield(mutex_t *lock, const char *file, const char *func, 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 _mutex_unlock(mutex_t *lock, const char *file, const char *func, const int line);
void _wr_lock(pthread_rwlock_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);
int _wr_trylock(pthread_rwlock_t *lock, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line); void mutex_destroy(mutex_t *lock);
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 _wr_lock(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); int _wr_trylock(rwlock_t *lock, __maybe_unused const char *file, __maybe_unused const char *func, __maybe_unused const int line);
void _rd_unlock_noyield(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);
void _wr_unlock_noyield(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);
void _rd_unlock(pthread_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(pthread_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 _mutex_init(pthread_mutex_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 mutex_destroy(pthread_mutex_t *lock); void _wr_unlock(rwlock_t *lock, const char *file, const char *func, const int line);
void _rwlock_init(pthread_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_destroy(pthread_rwlock_t *lock); 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 _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_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_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_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); 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_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_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 _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_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); void _cksem_post(sem_t *sem, const char *file, const char *func, const int line);

14
src/stratifier.c

@ -308,10 +308,10 @@ struct stratifier_data {
pool_stats_t stats; pool_stats_t stats;
/* Protects changes to pool stats */ /* Protects changes to pool stats */
pthread_mutex_t stats_lock; mutex_t stats_lock;
/* Serialises sends/receives to ckdb if possible */ /* Serialises sends/receives to ckdb if possible */
pthread_mutex_t ckdb_lock; mutex_t ckdb_lock;
bool ckdb_offline; bool ckdb_offline;
@ -359,14 +359,14 @@ struct stratifier_data {
cklock_t instance_lock; cklock_t instance_lock;
share_t *shares; share_t *shares;
pthread_mutex_t share_lock; mutex_t share_lock;
int64_t shares_generated; int64_t shares_generated;
/* Linked list of block solves, added to during submission, removed on /* 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 * accept/reject. It is likely we only ever have one solve on here but
* you never know... */ * you never know... */
pthread_mutex_t block_lock; mutex_t block_lock;
ckmsg_t *block_solves; ckmsg_t *block_solves;
/* Generator message priority */ /* Generator message priority */
@ -374,7 +374,7 @@ struct stratifier_data {
proxy_t *proxy; /* Current proxy in use */ proxy_t *proxy; /* Current proxy in use */
proxy_t *proxies; /* Hashlist of all proxies */ 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; 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 */ /* 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; bool ret;
@ -3838,7 +3838,7 @@ static bool test_and_set(bool *val, pthread_mutex_t *lock)
return ret; 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; bool ret;

Loading…
Cancel
Save