Patch ckpool: enable socket API responses

Upstream ckpool-solo stubs out send_api_response as a no-op, so the
stratifier socket accepts commands like poolstats/users/workers but
never writes anything back — kamado-api always gets EOF.

Replace the stub with a real implementation: serialize the json_t
with json_dumps, write via send_unix_msg, and free. The stratum_loop
retry label handles socket cleanup.
This commit is contained in:
satoshi
2026-04-17 23:13:04 +03:00
parent 64d8af407d
commit 8de767646d
@@ -0,0 +1,26 @@
diff --git a/src/ckpool.h b/src/ckpool.h
index 0921496..58fbc95 100644
--- a/src/ckpool.h
+++ b/src/ckpool.h
@@ -394,7 +394,20 @@ struct apimsg {
static inline void ckpool_api(ckpool_t __maybe_unused *ckp, apimsg_t __maybe_unused *apimsg) {};
static inline json_t *json_encode_errormsg(json_error_t __maybe_unused *err_val) { return NULL; };
static inline json_t *json_errormsg(const char __maybe_unused *fmt, ...) { return NULL; };
-static inline void send_api_response(json_t __maybe_unused *val, const int __maybe_unused sockd) {};
+
+/* Send a JSON value as a length-prefixed unix message so that external
+ * tools (kamado-api) can query live pool/user/worker stats via the
+ * stratifier socket. The caller (stratum_loop retry:) closes sockd. */
+static inline void send_api_response(json_t *val, const int sockd)
+{
+ char *response;
+
+ response = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER);
+ json_decref(val);
+ if (response)
+ send_unix_msg(sockd, response);
+ free(response);
+}
/* Subclients have client_ids in the high bits. Returns the value of the parent
* client if one exists. */