From 501f4cd6eca32eac678ae64828c58f143ce5bb4e Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 7 Mar 2013 19:59:30 +1100 Subject: [PATCH] Clear the socket of anything in the receive buffer if we're going to retry connecting. --- util.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/util.c b/util.c index e15ab5a5..44ab0b55 100644 --- a/util.c +++ b/util.c @@ -1525,13 +1525,16 @@ bool initiate_stratum(struct pool *pool) sockd = true; resend: - if (!recvd) { + if (recvd) { + /* Get rid of any crap lying around if we're resending */ + clear_sock(pool); + sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", swork_id++); + } else { if (pool->sessionid) sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"VERSION"\", \"%s\"]}", swork_id++, pool->sessionid); else sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"VERSION"\"]}", swork_id++); - } else - sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", swork_id++); + } if (!__stratum_send(pool, s, strlen(s))) { applog(LOG_DEBUG, "Failed to send s in initiate_stratum");