Browse Source

Remove getwork command from workio_cmd queues and do them directly from queue_request.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
59ddfd07a7
  1. 45
      cgminer.c

45
cgminer.c

@ -62,12 +62,7 @@
# define USE_FPGA # define USE_FPGA
#endif #endif
enum workio_commands {
WC_GET_WORK,
};
struct workio_cmd { struct workio_cmd {
enum workio_commands cmd;
struct thr_info *thr; struct thr_info *thr;
struct work *work; struct work *work;
struct pool *pool; struct pool *pool;
@ -2735,11 +2730,6 @@ static void workio_cmd_free(struct workio_cmd *wc)
if (!wc) if (!wc)
return; return;
switch (wc->cmd) {
default: /* do nothing */
break;
}
memset(wc, 0, sizeof(*wc)); /* poison */ memset(wc, 0, sizeof(*wc)); /* poison */
free(wc); free(wc);
} }
@ -3207,20 +3197,6 @@ out:
return NULL; return NULL;
} }
/* As per the submit work system, we try to reuse the existing curl handles,
* but start recruiting extra connections if we start accumulating queued
* requests */
static bool workio_get_work(struct workio_cmd *wc)
{
pthread_t get_thread;
if (unlikely(pthread_create(&get_thread, NULL, get_work_thread, (void *)wc))) {
applog(LOG_ERR, "Failed to create get_work_thread");
return false;
}
return true;
}
static bool stale_work(struct work *work, bool share) static bool stale_work(struct work *work, bool share)
{ {
struct timeval now; struct timeval now;
@ -4455,16 +4431,6 @@ static void *workio_thread(void *userdata)
ok = false; ok = false;
break; break;
} }
/* process workio_cmd */
switch (wc->cmd) {
case WC_GET_WORK:
ok = workio_get_work(wc);
break;
default:
ok = false;
break;
}
} }
tq_freeze(mythr->q); tq_freeze(mythr->q);
@ -5071,6 +5037,7 @@ static bool queue_request(void)
int ts, tq, maxq = opt_queue + mining_threads; int ts, tq, maxq = opt_queue + mining_threads;
struct pool *pool, *cp; struct pool *pool, *cp;
struct workio_cmd *wc; struct workio_cmd *wc;
pthread_t get_thread;
bool lagging; bool lagging;
ts = total_staged(); ts = total_staged();
@ -5096,17 +5063,13 @@ static bool queue_request(void)
return false; return false;
} }
wc->cmd = WC_GET_WORK;
wc->pool = pool; wc->pool = pool;
applog(LOG_DEBUG, "Queueing getwork request to work thread"); applog(LOG_DEBUG, "Queueing getwork request to work thread");
/* send work request to workio thread */ /* send work request to get_work_thread */
if (unlikely(!tq_push(thr_info[work_thr_id].q, wc))) { if (unlikely(pthread_create(&get_thread, NULL, get_work_thread, (void *)wc)))
applog(LOG_ERR, "Failed to tq_push in queue_request"); quit(1, "Failed to create get_work_thread in queue_request");
workio_cmd_free(wc);
return false;
}
return true; return true;
} }

Loading…
Cancel
Save