Browse Source

Log all ckdb requests to the rotating ckdb log

master
Con Kolivas 11 years ago
parent
commit
645b94c949
  1. 8
      src/ckpool.c
  2. 4
      src/ckpool.h
  3. 6
      src/stratifier.c

8
src/ckpool.c

@ -325,7 +325,7 @@ out:
/* Send a json msg to ckdb with its idmsg and return the response, consuming /* Send a json msg to ckdb with its idmsg and return the response, consuming
* the json on success */ * the json on success */
char *_json_ckdb_call(const ckpool_t *ckp, const char *idmsg, json_t *val, char *_json_ckdb_call(const ckpool_t *ckp, const char *idmsg, json_t *val, bool logged,
const char *file, const char *func, const int line) const char *file, const char *func, const int line)
{ {
char *msg = NULL, *dump, *buf = NULL; char *msg = NULL, *dump, *buf = NULL;
@ -336,6 +336,12 @@ char *_json_ckdb_call(const ckpool_t *ckp, const char *idmsg, json_t *val,
return buf; return buf;
} }
ASPRINTF(&msg, "id.%s.json=%s", idmsg, dump); ASPRINTF(&msg, "id.%s.json=%s", idmsg, dump);
if (!logged) {
char logname[512];
snprintf(logname, 511, "%s%s", ckp->logdir, ckp->ckdb_name);
rotating_log(logname, msg);
}
free(dump); free(dump);
LOGDEBUG("Sending ckdb: %s", msg); LOGDEBUG("Sending ckdb: %s", msg);
buf = _send_recv_ckdb(ckp, msg, file, func, line); buf = _send_recv_ckdb(ckp, msg, file, func, line);

4
src/ckpool.h

@ -136,9 +136,9 @@ char *_send_recv_proc(proc_instance_t *pi, const char *msg, const char *file, co
#define send_recv_proc(pi, msg) _send_recv_proc(pi, msg, __FILE__, __func__, __LINE__) #define send_recv_proc(pi, msg) _send_recv_proc(pi, msg, __FILE__, __func__, __LINE__)
char *_send_recv_ckdb(const ckpool_t *ckp, const char *msg, const char *file, const char *func, const int line); char *_send_recv_ckdb(const ckpool_t *ckp, const char *msg, const char *file, const char *func, const int line);
#define send_recv_ckdb(ckp, msg) _send_recv_ckdb(ckp, msg, __FILE__, __func__, __LINE__) #define send_recv_ckdb(ckp, msg) _send_recv_ckdb(ckp, msg, __FILE__, __func__, __LINE__)
char *_json_ckdb_call(const ckpool_t *ckp, const char *idmsg, json_t *val, char *_json_ckdb_call(const ckpool_t *ckp, const char *idmsg, json_t *val, bool logged,
const char *file, const char *func, const int line); const char *file, const char *func, const int line);
#define json_ckdb_call(ckp, idmsg, val) _json_ckdb_call(ckp, idmsg, val, __FILE__, __func__, __LINE__) #define json_ckdb_call(ckp, idmsg, val, logged) _json_ckdb_call(ckp, idmsg, val, logged, __FILE__, __func__, __LINE__)
json_t *json_rpc_call(connsock_t *cs, const char *rpc_req); json_t *json_rpc_call(connsock_t *cs, const char *rpc_req);

6
src/stratifier.c

@ -1171,7 +1171,7 @@ static bool send_recv_auth(stratum_instance_t *client)
"createby", "code", "createby", "code",
"createcode", __func__, "createcode", __func__,
"createinet", "127.0.0.1"); "createinet", "127.0.0.1");
buf = json_ckdb_call(client->ckp, ckdb_ids[ID_AUTH], val); buf = json_ckdb_call(client->ckp, ckdb_ids[ID_AUTH], val, false);
if (likely(buf)) { if (likely(buf)) {
char *secondaryuserid, *response = alloca(128); char *secondaryuserid, *response = alloca(128);
@ -2106,6 +2106,7 @@ static void *ckdbqueue(void *arg)
rename_proc("ckdbqueue"); rename_proc("ckdbqueue");
while (42) { while (42) {
bool logged = false;
char *buf = NULL; char *buf = NULL;
ckdb_msg_t *msg; ckdb_msg_t *msg;
@ -2121,11 +2122,12 @@ static void *ckdbqueue(void *arg)
continue; continue;
while (!buf) { while (!buf) {
buf = json_ckdb_call(ckp, ckdb_ids[msg->idtype], msg->val); buf = json_ckdb_call(ckp, ckdb_ids[msg->idtype], msg->val, logged);
if (unlikely(!buf)) { if (unlikely(!buf)) {
LOGWARNING("Failed to talk to ckdb, queueing messages"); LOGWARNING("Failed to talk to ckdb, queueing messages");
sleep(5); sleep(5);
} }
logged = true;
} }
LOGINFO("Got %s ckdb response: %s", ckdb_ids[msg->idtype], buf); LOGINFO("Got %s ckdb response: %s", ckdb_ids[msg->idtype], buf);
free(buf); free(buf);

Loading…
Cancel
Save