Browse Source

Serialise all json_rpc_calls and responses

master
Con Kolivas 9 years ago
parent
commit
853bed8281
  1. 3
      src/ckpool.c
  2. 2
      src/ckpool.h
  3. 2
      src/generator.c

3
src/ckpool.c

@ -745,6 +745,8 @@ json_t *json_rpc_call(connsock_t *cs, const char *rpc_req)
double elapsed;
int len, ret;
/* Serialise all calls in case we use cs from multiple threads */
cksem_wait(&cs->sem);
if (unlikely(cs->fd < 0)) {
LOGWARNING("FD %d invalid in %s", cs->fd, __func__);
goto out;
@ -839,6 +841,7 @@ out_empty:
out:
free(http_req);
dealloc(cs->buf);
cksem_post(&cs->sem);
return val;
}

2
src/ckpool.h

@ -79,6 +79,8 @@ struct connsock {
char *buf;
int bufofs;
int buflen;
/* Semaphore used to serialise request/responses */
sem_t sem;
};
typedef struct connsock connsock_t;

2
src/generator.c

@ -1698,6 +1698,8 @@ static int server_mode(ckpool_t *ckp, proc_instance_t *pi)
si->auth = ckp->btcdauth[i];
si->pass = ckp->btcdpass[i];
si->notify = ckp->btcdnotify[i];
cksem_init(&si->cs.sem);
cksem_post(&si->cs.sem);
}
ret = gen_loop(pi);

Loading…
Cancel
Save