mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-02 10:04:33 +00:00
Submit work async is still unreliable and only used for cpu mining, so back it out for now.
This commit is contained in:
parent
60f0bb19de
commit
18f8b0f9a5
64
cpu-miner.c
64
cpu-miner.c
@ -643,68 +643,6 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct submit_data {
|
||||
struct thr_info *thr;
|
||||
struct work *work_in;
|
||||
pthread_t pth;
|
||||
};
|
||||
|
||||
static void *submit_work(void *userdata)
|
||||
{
|
||||
struct submit_data *sd = (struct submit_data *)userdata;
|
||||
struct workio_cmd *wc;
|
||||
|
||||
/* fill out work request message */
|
||||
wc = calloc(1, sizeof(*wc));
|
||||
if (unlikely(!wc))
|
||||
goto out;
|
||||
|
||||
wc->u.work = malloc(sizeof(struct work));
|
||||
if (unlikely(!wc->u.work))
|
||||
goto err_out;
|
||||
|
||||
wc->cmd = WC_SUBMIT_WORK;
|
||||
wc->thr = sd->thr;
|
||||
memcpy(wc->u.work, &sd->work_in, sizeof(struct work));
|
||||
|
||||
/* send solution to workio thread */
|
||||
if (unlikely(!tq_push(thr_info[work_thr_id].q, wc)))
|
||||
goto err_out;
|
||||
|
||||
goto out;
|
||||
|
||||
err_out:
|
||||
workio_cmd_free(wc);
|
||||
out:
|
||||
pthread_detach(pthread_self());
|
||||
free(sd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool submit_work_async(struct thr_info *thr, const struct work *work_in)
|
||||
{
|
||||
struct submit_data *sd = malloc(sizeof(struct submit_data));
|
||||
if (unlikely(!sd)) {
|
||||
applog(LOG_ERR, "Failed to malloc sd in submit_work_async");
|
||||
return false;
|
||||
}
|
||||
sd->work_in = malloc(sizeof(struct work));
|
||||
if (unlikely(!sd->work_in)) {
|
||||
applog(LOG_ERR, "Failed to malloc work_in in submit_work_async");
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(sd->work_in, work_in, sizeof(struct work));
|
||||
/* Pass the thread id to the work struct for per-thread accounting */
|
||||
sd->work_in->thr_id = thr->id;
|
||||
|
||||
if (pthread_create(&sd->pth, NULL, submit_work, (void *)sd)) {
|
||||
applog(LOG_ERR, "Failed to create submit_thread");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool submit_work_sync(struct thr_info *thr, const struct work *work_in)
|
||||
{
|
||||
struct workio_cmd *wc;
|
||||
@ -865,7 +803,7 @@ static void *miner_thread(void *userdata)
|
||||
if (unlikely(rc)) {
|
||||
if (opt_debug)
|
||||
applog(LOG_DEBUG, "CPU %d found something?", cpu_from_thr_id(thr_id));
|
||||
if (!submit_work_async(mythr, &work))
|
||||
if (!submit_work_sync(mythr, &work))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user