Browse Source

Merge branch 'master' of bitbucket.org:ckolivas/ckpool

master
Con Kolivas 10 years ago
parent
commit
d0faecad64
  1. 22
      src/ckdb.c

22
src/ckdb.c

@ -723,6 +723,8 @@ typedef struct logqueue {
static K_LIST *logqueue_free; static K_LIST *logqueue_free;
static K_STORE *logqueue_store; static K_STORE *logqueue_store;
static pthread_mutex_t wq_waitlock;
static pthread_cond_t wq_waitcond;
// WORKQUEUE // WORKQUEUE
typedef struct workqueue { typedef struct workqueue {
@ -6300,6 +6302,8 @@ static bool setup_data()
cklock_init(&fpm_lock); cklock_init(&fpm_lock);
cksem_init(&socketer_sem); cksem_init(&socketer_sem);
mutex_init(&wq_waitlock);
cond_init(&wq_waitcond);
alloc_storage(); alloc_storage();
@ -8606,6 +8610,9 @@ static void *socketer(__maybe_unused void *arg)
K_WLOCK(workqueue_free); K_WLOCK(workqueue_free);
k_add_tail(workqueue_store, item); k_add_tail(workqueue_store, item);
K_WUNLOCK(workqueue_free); K_WUNLOCK(workqueue_free);
mutex_lock(&wq_waitlock);
pthread_cond_signal(&wq_waitcond);
mutex_unlock(&wq_waitlock);
break; break;
// Code error // Code error
default: default:
@ -8984,8 +8991,19 @@ static void *listener(void *arg)
if (wq_item) { if (wq_item) {
process_queued(conn, wq_item); process_queued(conn, wq_item);
tick(); tick();
} else } else {
cksleep_ms(4); const ts_t tsdiff = {0, 420000000};
tv_t now;
ts_t abs;
tv_time(&now);
tv_to_ts(&abs, &now);
timeraddspec(&abs, &tsdiff);
mutex_lock(&wq_waitlock);
pthread_cond_timedwait(&wq_waitcond, &wq_waitlock, &abs);
mutex_unlock(&wq_waitlock);
}
} }
PQfinish(conn); PQfinish(conn);

Loading…
Cancel
Save