Commit b86a893981a29da01f53d9b41e0037f7195f88e5

Con Kolivas 2012-09-28T05:30:36

Append \n in the sock_send function instead of adding it when constructing json in stratum.

diff --git a/util.c b/util.c
index db100ec..d97fc90 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)