Browse Source

Merge commit '85c94bb' into bfgminer

Luke Dashjr 14 years ago
parent
commit
cfd572dab1
3 changed files with 19 additions and 19 deletions
  1. 1 1
      api.c
  2. 18 15
      miner.c
  3. 0 3
      miner.h

+ 1 - 1
api.c

@@ -1849,7 +1849,7 @@ void notifystatus(int device, struct cgpu_info *cgpu, bool isjson)
 	// ALL counters (and only counters) must start the name with a '*'
 	// ALL counters (and only counters) must start the name with a '*'
 	// Simplifies future external support for adding new counters
 	// Simplifies future external support for adding new counters
 	sprintf(buf, isjson
 	sprintf(buf, isjson
-		? "%s{\"NOTIFY\":%d,\"Name\":\"%s\",\"ID\":%d,\"Last Well\":%lu,\"Last Not Well\":%lu,\"Reason Not Well\":\"%s\",\"*Thread Fail Init\":%d,\"*Thread Zero Hash\":%d,\"*Thread Fail Queue\":%d,\"*Dev Sick Idle 60s\":%d,\"*Dev Dead Idle 600s\":%d,\"*Dev Nostart\":%d,\"*Dev Over Heat\":%d,\"*Dev Thermal Cutoff\":%d}" JSON_CLOSE
+		? "%s{\"NOTIFY\":%d,\"Name\":\"%s\",\"ID\":%d,\"Last Well\":%lu,\"Last Not Well\":%lu,\"Reason Not Well\":\"%s\",\"*Thread Fail Init\":%d,\"*Thread Zero Hash\":%d,\"*Thread Fail Queue\":%d,\"*Dev Sick Idle 60s\":%d,\"*Dev Dead Idle 600s\":%d,\"*Dev Nostart\":%d,\"*Dev Over Heat\":%d,\"*Dev Thermal Cutoff\":%d}"
 		: "%sNOTIFY=%d,Name=%s,ID=%d,Last Well=%lu,Last Not Well=%lu,Reason Not Well=%s,*Thread Fail Init=%d,*Thread Zero Hash=%d,*Thread Fail Queue=%d,*Dev Sick Idle 60s=%d,*Dev Dead Idle 600s=%d,*Dev Nostart=%d,*Dev Over Heat=%d,*Dev Thermal Cutoff=%d" SEPSTR,
 		: "%sNOTIFY=%d,Name=%s,ID=%d,Last Well=%lu,Last Not Well=%lu,Reason Not Well=%s,*Thread Fail Init=%d,*Thread Zero Hash=%d,*Thread Fail Queue=%d,*Dev Sick Idle 60s=%d,*Dev Dead Idle 600s=%d,*Dev Nostart=%d,*Dev Over Heat=%d,*Dev Thermal Cutoff=%d" SEPSTR,
 		(isjson && (device > 0)) ? COMMA : BLANK,
 		(isjson && (device > 0)) ? COMMA : BLANK,
 		device, cgpu->api->name, cgpu->device_id,
 		device, cgpu->api->name, cgpu->device_id,

+ 18 - 15
miner.c

@@ -1983,6 +1983,7 @@ static void *get_work_thread(void *userdata)
 {
 {
 	struct pool *pool = (struct pool *)userdata;
 	struct pool *pool = (struct pool *)userdata;
 	struct workio_cmd *wc;
 	struct workio_cmd *wc;
+	CURL *curl;
 
 
 	pthread_detach(pthread_self());
 	pthread_detach(pthread_self());
 
 
@@ -1991,9 +1992,8 @@ static void *get_work_thread(void *userdata)
 	if (!pool->getwork_q)
 	if (!pool->getwork_q)
 		quit(1, "Failed to tq_new in get_work_thread");
 		quit(1, "Failed to tq_new in get_work_thread");
 
 
-	/* getwork_curl never cleared */
-	pool->getwork_curl = curl_easy_init();
-	if (unlikely(!pool->getwork_curl))
+	curl = curl_easy_init();
+	if (unlikely(!curl))
 		quit(1, "Failed to initialise pool getwork CURL");
 		quit(1, "Failed to initialise pool getwork CURL");
 
 
 	while ((wc = tq_pop(pool->getwork_q, NULL)) != NULL) {
 	while ((wc = tq_pop(pool->getwork_q, NULL)) != NULL) {
@@ -2010,7 +2010,7 @@ static void *get_work_thread(void *userdata)
 		ret_work->pool = pool;
 		ret_work->pool = pool;
 
 
 		/* obtain new work from bitcoin via JSON-RPC */
 		/* obtain new work from bitcoin via JSON-RPC */
-		while (!get_upstream_work(ret_work, pool->getwork_curl)) {
+		while (!get_upstream_work(ret_work, curl)) {
 			if (unlikely((opt_retries >= 0) && (++failures > opt_retries))) {
 			if (unlikely((opt_retries >= 0) && (++failures > opt_retries))) {
 				applog(LOG_ERR, "json_rpc_call failed, terminating workio thread");
 				applog(LOG_ERR, "json_rpc_call failed, terminating workio thread");
 				free_work(ret_work);
 				free_work(ret_work);
@@ -2037,6 +2037,7 @@ static void *get_work_thread(void *userdata)
 		workio_cmd_free(wc);
 		workio_cmd_free(wc);
 	}
 	}
 
 
+	curl_easy_cleanup(curl);
 	return NULL;
 	return NULL;
 }
 }
 
 
@@ -2098,7 +2099,7 @@ static bool workio_get_work(struct workio_cmd *wc)
 	struct pool *pool = select_pool(wc->lagging);
 	struct pool *pool = select_pool(wc->lagging);
 	pthread_t get_thread;
 	pthread_t get_thread;
 
 
-	if (list_empty(&pool->getwork_q->q))
+	if (list_empty(&pool->getwork_q->q) || pool->submit_fail)
 		return tq_push(pool->getwork_q, wc);
 		return tq_push(pool->getwork_q, wc);
 
 
 	if (unlikely(pthread_create(&get_thread, NULL, get_extra_work, (void *)wc))) {
 	if (unlikely(pthread_create(&get_thread, NULL, get_extra_work, (void *)wc))) {
@@ -2139,6 +2140,7 @@ static void *submit_work_thread(void *userdata)
 {
 {
 	struct pool *pool = (struct pool *)userdata;
 	struct pool *pool = (struct pool *)userdata;
 	struct workio_cmd *wc;
 	struct workio_cmd *wc;
+	CURL *curl;
 
 
 	pthread_detach(pthread_self());
 	pthread_detach(pthread_self());
 
 
@@ -2147,9 +2149,8 @@ static void *submit_work_thread(void *userdata)
 	if (!pool->submit_q )
 	if (!pool->submit_q )
 		quit(1, "Failed to tq_new in submit_work_thread");
 		quit(1, "Failed to tq_new in submit_work_thread");
 
 
-	/* submit_curl never cleared */
-	pool->submit_curl = curl_easy_init();
-	if (unlikely(!pool->submit_curl))
+	curl = curl_easy_init();
+	if (unlikely(!curl))
 		quit(1, "Failed to initialise pool submit CURL");
 		quit(1, "Failed to initialise pool submit CURL");
 
 
 	while ((wc = tq_pop(pool->submit_q, NULL)) != NULL) {
 	while ((wc = tq_pop(pool->submit_q, NULL)) != NULL) {
@@ -2175,9 +2176,9 @@ static void *submit_work_thread(void *userdata)
 		}
 		}
 
 
 		/* submit solution to bitcoin via JSON-RPC */
 		/* submit solution to bitcoin via JSON-RPC */
-		while (!submit_upstream_work(work, pool->submit_curl)) {
-			if (!opt_submit_stale && stale_work(work, true) && !pool->submit_old) {
-				applog(LOG_NOTICE, "Stale share detected on submit retry, discarding");
+		while (!submit_upstream_work(work, curl)) {
+			if (stale_work(work, true)) {
+				applog(LOG_NOTICE, "Share became stale while retrying submit, discarding");
 				total_stale++;
 				total_stale++;
 				pool->stale_shares++;
 				pool->stale_shares++;
 				break;
 				break;
@@ -2198,6 +2199,7 @@ static void *submit_work_thread(void *userdata)
 		workio_cmd_free(wc);
 		workio_cmd_free(wc);
 	}
 	}
 
 
+	curl_easy_cleanup(curl);
 	return NULL;
 	return NULL;
 }
 }
 
 
@@ -2229,8 +2231,8 @@ static void *submit_extra_work(void *userdata)
 
 
 	/* submit solution to bitcoin via JSON-RPC */
 	/* submit solution to bitcoin via JSON-RPC */
 	while (!submit_upstream_work(work, curl)) {
 	while (!submit_upstream_work(work, curl)) {
-		if (!opt_submit_stale && stale_work(work, true)) {
-			applog(LOG_NOTICE, "Stale share detected, discarding");
+		if (stale_work(work, true)) {
+			applog(LOG_NOTICE, "Share became stale while retrying submit, discarding");
 			total_stale++;
 			total_stale++;
 			pool->stale_shares++;
 			pool->stale_shares++;
 			break;
 			break;
@@ -2260,10 +2262,11 @@ out:
  * any size hardware */
  * any size hardware */
 static bool workio_submit_work(struct workio_cmd *wc)
 static bool workio_submit_work(struct workio_cmd *wc)
 {
 {
+	struct pool *pool = wc->u.work->pool;
 	pthread_t submit_thread;
 	pthread_t submit_thread;
 
 
-	if (list_empty(&wc->u.work->pool->submit_q->q))
-		return tq_push(wc->u.work->pool->submit_q, wc);
+	if (list_empty(&pool->submit_q->q) || pool->submit_fail)
+		return tq_push(pool->submit_q, wc);
 
 
 	if (unlikely(pthread_create(&submit_thread, NULL, submit_extra_work, (void *)wc))) {
 	if (unlikely(pthread_create(&submit_thread, NULL, submit_extra_work, (void *)wc))) {
 		applog(LOG_ERR, "Failed to create submit_work_thread");
 		applog(LOG_ERR, "Failed to create submit_work_thread");

+ 0 - 3
miner.h

@@ -632,9 +632,6 @@ struct pool {
 	pthread_t longpoll_thread;
 	pthread_t longpoll_thread;
 	pthread_t submit_thread;
 	pthread_t submit_thread;
 	pthread_t getwork_thread;
 	pthread_t getwork_thread;
-
-	CURL *submit_curl;
-	CURL *getwork_curl;
 };
 };
 
 
 struct work {
 struct work {