From b86a893981a29da01f53d9b41e0037f7195f88e5 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 28 Sep 2012 05:30:36 +1000 Subject: [PATCH] Append \n in the sock_send function instead of adding it when constructing json in stratum. --- util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util.c b/util.c index db100ecc..d97fc906 100644 --- a/util.c +++ b/util.c @@ -846,6 +846,7 @@ bool extract_sockaddr(struct pool *pool, char *url) return true; } +/* Send a single command across a socket, appending \n to it */ static bool sock_send(int sock, char *s, ssize_t len) { ssize_t sent = 0; @@ -853,6 +854,9 @@ static bool sock_send(int sock, char *s, ssize_t len) if (opt_protocol) applog(LOG_DEBUG, "SEND: %s", s); + strcat(s, "\n"); + len++; + while (len > 0 ) { sent = send(sock, s + sent, len, 0); if (SOCKETFAIL(sent)) @@ -1006,7 +1010,7 @@ bool auth_stratum(struct pool *pool) bool ret = false; s = alloca(RECVSIZE); - sprintf(s, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"%s\"]}\n", + sprintf(s, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"%s\"]}", pool->swork.id++, pool->rpc_user, pool->rpc_pass); while (sock_full(pool->sock, false)) { @@ -1033,7 +1037,7 @@ bool initiate_stratum(struct pool *pool) bool ret = false; s = alloca(RECVSIZE); - sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}\n", pool->swork.id++); + sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", pool->swork.id++); pool->sock = socket(AF_INET, SOCK_STREAM, 0); if (pool->sock == INVSOCK)