Browse Source

Only internally test for block changes when the work matches the current pool to prevent interleaved block change timing on multipools.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
b534ad0aad
  1. 50
      main.c

50
main.c

@ -1095,6 +1095,11 @@ static bool stale_work(struct work *work)
bool ret = false; bool ret = false;
char *hexstr; char *hexstr;
/* Only use the primary pool for determination as the work may
* interleave at times of new blocks */
if (work->pool != current_pool())
return ret;
if (!strncmp(blank, current_block, 36)) if (!strncmp(blank, current_block, 36))
return ret; return ret;
@ -1304,28 +1309,18 @@ static void set_curblock(char *hexstr)
tm.tm_sec); tm.tm_sec);
} }
static void *stage_thread(void *userdata) static void test_work_current(struct work *work)
{ {
struct thr_info *mythr = userdata;
bool ok = true;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
while (ok) {
struct work *work = NULL;
char *hexstr; char *hexstr;
work = tq_pop(mythr->q, NULL); /* Only use the primary pool for determination */
if (unlikely(!work)) { if (work->pool != current_pool())
applog(LOG_ERR, "Failed to tq_pop in stage_thread"); return;
ok = false;
break;
}
hexstr = bin2hex(work->data, 36); hexstr = bin2hex(work->data, 36);
if (unlikely(!hexstr)) { if (unlikely(!hexstr)) {
applog(LOG_ERR, "stage_thread OOM"); applog(LOG_ERR, "stage_thread OOM");
break; return;
} }
/* current_block is blanked out on successful longpoll */ /* current_block is blanked out on successful longpoll */
@ -1336,9 +1331,8 @@ static void *stage_thread(void *userdata)
applog(LOG_WARNING, "New block detected on network before longpoll, waiting on fresh work"); applog(LOG_WARNING, "New block detected on network before longpoll, waiting on fresh work");
else else
applog(LOG_WARNING, "New block detected on network, waiting on fresh work"); applog(LOG_WARNING, "New block detected on network, waiting on fresh work");
/* As we can't flush the work from here, signal /* As we can't flush the work from here, signal the
* the wakeup thread to restart all the * wakeup thread to restart all the threads */
* threads */
work_restart[watchdog_thr_id].restart = 1; work_restart[watchdog_thr_id].restart = 1;
set_curblock(hexstr); set_curblock(hexstr);
} }
@ -1347,6 +1341,26 @@ static void *stage_thread(void *userdata)
memcpy(longpoll_block, hexstr, 36); memcpy(longpoll_block, hexstr, 36);
} }
free(hexstr); free(hexstr);
}
static void *stage_thread(void *userdata)
{
struct thr_info *mythr = userdata;
bool ok = true;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
while (ok) {
struct work *work = NULL;
work = tq_pop(mythr->q, NULL);
if (unlikely(!work)) {
applog(LOG_ERR, "Failed to tq_pop in stage_thread");
ok = false;
break;
}
test_work_current(work);
if (unlikely(!tq_push(getq, work))) { if (unlikely(!tq_push(getq, work))) {
applog(LOG_ERR, "Failed to tq_push work in stage_thread"); applog(LOG_ERR, "Failed to tq_push work in stage_thread");

Loading…
Cancel
Save