Browse Source

Allow the loglevel to be changed on the fly

master
Con Kolivas 11 years ago
parent
commit
e40128a2da
  1. 25
      src/ckpool.c
  2. 4
      src/connector.c
  3. 4
      src/generator.c
  4. 2
      src/stratifier.c

25
src/ckpool.c

@ -130,6 +130,17 @@ void ckmsgq_add(ckmsgq_t *ckmsgq, void *data)
mutex_unlock(&ckmsgq->lock); mutex_unlock(&ckmsgq->lock);
} }
static void broadcast_proc(ckpool_t *ckp, const char *buf)
{
int i;
for (i = 0; i < ckp->proc_instances; i++) {
proc_instance_t *pi = ckp->children[i];
send_proc(pi, buf);
}
}
/* Listen for incoming global requests. Always returns a response if possible */ /* Listen for incoming global requests. Always returns a response if possible */
static void *listener(void *arg) static void *listener(void *arg)
{ {
@ -159,6 +170,20 @@ retry:
} else if (!strncasecmp(buf, "ping", 4)) { } else if (!strncasecmp(buf, "ping", 4)) {
LOGDEBUG("Listener received ping request"); LOGDEBUG("Listener received ping request");
send_unix_msg(sockd, "pong"); send_unix_msg(sockd, "pong");
} else if (!strncasecmp(buf, "loglevel", 8)) {
int loglevel;
if (sscanf(buf, "loglevel=%d", &loglevel) != 1) {
LOGWARNING("Failed to parse loglevel message %s", buf);
send_unix_msg(sockd, "Failed");
} else if (loglevel < LOG_EMERG || loglevel > LOG_DEBUG) {
LOGWARNING("Invalid loglevel %d sent", loglevel);
send_unix_msg(sockd, "Invalid");
} else {
ckp->loglevel = loglevel;
broadcast_proc(ckp, buf);
send_unix_msg(sockd, "success");
}
} else if (!strncasecmp(buf, "getfd", 5)) { } else if (!strncasecmp(buf, "getfd", 5)) {
char *msg; char *msg;

4
src/connector.c

@ -506,6 +506,10 @@ retry:
ci->accept = false; ci->accept = false;
goto retry; goto retry;
} }
if (!strncasecmp(buf, "loglevel", 8)) {
sscanf(buf, "loglevel=%d", &ckp->loglevel);
goto retry;
}
LOGDEBUG("Connector received message: %s", buf); LOGDEBUG("Connector received message: %s", buf);
if (!strncasecmp(buf, "shutdown", 8)) if (!strncasecmp(buf, "shutdown", 8))

4
src/generator.c

@ -279,6 +279,8 @@ retry:
LOGNOTICE("Submitting block data!"); LOGNOTICE("Submitting block data!");
if (submit_block(cs, buf + 12)) if (submit_block(cs, buf + 12))
send_proc(ckp->stratifier, "block"); send_proc(ckp->stratifier, "block");
} else if (!strncasecmp(buf, "loglevel", 8)) {
sscanf(buf, "loglevel=%d", &ckp->loglevel);
} else if (!strncasecmp(buf, "ping", 4)) { } else if (!strncasecmp(buf, "ping", 4)) {
LOGDEBUG("Generator received ping request"); LOGDEBUG("Generator received ping request");
send_unix_msg(sockd, "pong"); send_unix_msg(sockd, "pong");
@ -1253,6 +1255,8 @@ retry:
pthread_cancel(proxi->pth_precv); pthread_cancel(proxi->pth_precv);
pthread_cancel(proxi->pth_psend); pthread_cancel(proxi->pth_psend);
goto reconnect; goto reconnect;
} else if (!strncasecmp(buf, "loglevel", 8)) {
sscanf(buf, "loglevel=%d", &ckp->loglevel);
} else if (!strncasecmp(buf, "ping", 4)) { } else if (!strncasecmp(buf, "ping", 4)) {
LOGDEBUG("Proxy received ping request"); LOGDEBUG("Proxy received ping request");
send_unix_msg(sockd, "pong"); send_unix_msg(sockd, "pong");

2
src/stratifier.c

@ -963,6 +963,8 @@ retry:
} else if (!strncasecmp(buf, "block", 5)) { } else if (!strncasecmp(buf, "block", 5)) {
block_solve(ckp); block_solve(ckp);
update_base(ckp); update_base(ckp);
} else if (!strncasecmp(buf, "loglevel", 8)) {
sscanf(buf, "loglevel=%d", &ckp->loglevel);
} else { } else {
json_t *val = json_loads(buf, 0, NULL); json_t *val = json_loads(buf, 0, NULL);

Loading…
Cancel
Save