Commit c3e569ed9b203731ff91abf06ce1127f2c718a3a

Con Kolivas 2011-07-18T13:16:15

Copied the data to longpoll_block too early so the longpoll message will rarely be received. Submit longpoll's converted work after we've flushed requests since that will blank the current_block for stage_thread to see.

diff --git a/main.c b/main.c
index a5b0536..e986fd4 100644
--- a/main.c
+++ b/main.c
@@ -1891,11 +1891,6 @@ static void *longpoll_thread(void *userdata)
 		val = json_rpc_call(curl, lp_url, rpc_userpass, rpc_req,
 				    false, true);
 		if (likely(val)) {
-			memcpy(longpoll_block, current_block, 36);
-			convert_to_work(val);
-			failures = 0;
-			json_decref(val);
-
 			/* Keep track of who ordered a restart_threads to make
 			 * sure it's only done once per new block */
 			if (likely(!strncmp(longpoll_block, blank, 36) ||
@@ -1905,6 +1900,10 @@ static void *longpoll_thread(void *userdata)
 					restart_threads(true);
 			} else
 				applog(LOG_WARNING, "LONGPOLL received after new block already detected");
+
+			convert_to_work(val);
+			failures = 0;
+			json_decref(val);
 		} else {
 			/* Some pools regularly drop the longpoll request so
 			 * only see this as longpoll failure if it happens
@@ -1923,6 +1922,7 @@ static void *longpoll_thread(void *userdata)
 				goto out;
 			}
 		}
+		memcpy(longpoll_block, current_block, 36);
 	}
 
 out: