Browse Source

Look for received json messages in the stratifier first since they'll be the most common

master
Con Kolivas 10 years ago
parent
commit
6a4da2814c
  1. 18
      src/stratifier.c

18
src/stratifier.c

@ -1443,11 +1443,20 @@ retry:
dealloc(buf); dealloc(buf);
buf = recv_unix_msg(sockd); buf = recv_unix_msg(sockd);
if (!buf) { if (unlikely(!buf)) {
Close(sockd); Close(sockd);
LOGWARNING("Failed to get message in stratum_loop"); LOGWARNING("Failed to get message in stratum_loop");
goto retry; goto retry;
} }
if (likely(buf[0] == '{')) {
/* The bulk of the messages will be received json from the
* connector so look for this first. The srecv_process frees
* the buf heap ram */
ckmsgq_add(sdata->srecvs, buf);
Close(sockd);
buf = NULL;
goto retry;
}
if (cmdmatch(buf, "ping")) { if (cmdmatch(buf, "ping")) {
LOGDEBUG("Stratifier received ping request"); LOGDEBUG("Stratifier received ping request");
send_unix_msg(sockd, "pong"); send_unix_msg(sockd, "pong");
@ -1488,11 +1497,8 @@ retry:
reconnect_clients(sdata, buf); reconnect_clients(sdata, buf);
} else if (cmdmatch(buf, "loglevel")) { } else if (cmdmatch(buf, "loglevel")) {
sscanf(buf, "loglevel=%d", &ckp->loglevel); sscanf(buf, "loglevel=%d", &ckp->loglevel);
} else { } else
/* The srecv_process frees the buf heap ram */ LOGWARNING("Unhandled stratifier message: %s", buf);
ckmsgq_add(sdata->srecvs, buf);
buf = NULL;
}
goto retry; goto retry;
out: out:

Loading…
Cancel
Save