diff --git a/src/ckpool.c b/src/ckpool.c index afc8d4cc..f8d801d1 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -278,7 +278,7 @@ char *_send_recv_proc(proc_instance_t *pi, const char *msg, const char *file, co } sockd = open_unix_client(path); if (unlikely(sockd < 0)) { - LOGWARNING("Failed to open socket %s", path); + LOGWARNING("Failed to open socket %s in send_recv_proc", path); goto out; } if (unlikely(!send_unix_msg(sockd, msg))) @@ -292,6 +292,36 @@ out: return buf; } +/* As send_recv_proc but only to ckdb */ +char *_send_recv_ckdb(const char *path, const char *msg, const char *file, const char *func, const int line) +{ + char *buf = NULL; + int sockd; + + if (unlikely(!path || !strlen(path))) { + LOGERR("Attempted to send message %s to null path in send_recv_ckdb", msg ? msg : ""); + goto out; + } + if (unlikely(!msg || !strlen(msg))) { + LOGERR("Attempted to send null message to ckdb in send_recv_ckdb"); + goto out; + } + sockd = open_unix_client(path); + if (unlikely(sockd < 0)) { + LOGWARNING("Failed to open socket %s in send_recv_ckdb", path); + goto out; + } + if (unlikely(!send_unix_msg(sockd, msg))) + LOGWARNING("Failed to send %s to ckdb", msg); + else + buf = recv_unix_msg(sockd); + close(sockd); +out: + if (unlikely(!buf)) + LOGERR("Failure in send_recv_ckdb from %s %s:%d", file, func, line); + return buf; +} + json_t *json_rpc_call(connsock_t *cs, const char *rpc_req) { diff --git a/src/ckpool.h b/src/ckpool.h index d6266979..e7ce582c 100644 --- a/src/ckpool.h +++ b/src/ckpool.h @@ -134,6 +134,8 @@ bool _send_proc(proc_instance_t *pi, const char *msg, const char *file, const ch #define send_proc(pi, msg) _send_proc(pi, msg, __FILE__, __func__, __LINE__) char *_send_recv_proc(proc_instance_t *pi, const char *msg, const char *file, const char *func, const int line); #define send_recv_proc(pi, msg) _send_recv_proc(pi, msg, __FILE__, __func__, __LINE__) +char *_send_recv_ckdb(const char *path, const char *msg, const char *file, const char *func, const int line); +#define send_recv_ckdb(path, msg) _send_recv_ckdb(path, msg, __FILE__, __func__, __LINE__) json_t *json_rpc_call(connsock_t *cs, const char *rpc_req);