mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 23:08:07 +00:00
Prevent a deadlock with use of restart_threads by spawning a thread to send the driver flush work messages.
Conflicts: cgminer.c
This commit is contained in:
parent
39121183e1
commit
7dd8b316ac
16
cgminer.c
16
cgminer.c
@ -3671,12 +3671,14 @@ int restart_wait(struct thr_info *thr, unsigned int mstime)
|
||||
|
||||
static void flush_queue(struct cgpu_info *cgpu);
|
||||
|
||||
static void restart_threads(void)
|
||||
static void *restart_thread(void __maybe_unused *arg)
|
||||
{
|
||||
struct pool *cp = current_pool();
|
||||
struct cgpu_info *cgpu;
|
||||
int i, mt;
|
||||
|
||||
pthread_detach(pthread_self());
|
||||
|
||||
/* Artificially set the lagging flag to avoid pool not providing work
|
||||
* fast enough messages after every long poll */
|
||||
pool_tset(cp, &cp->lagging);
|
||||
@ -3702,6 +3704,18 @@ static void restart_threads(void)
|
||||
mutex_lock(&restart_lock);
|
||||
pthread_cond_broadcast(&restart_cond);
|
||||
mutex_unlock(&restart_lock);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* In order to prevent a deadlock via the various drv->flush_work
|
||||
* implementations we send the restart messages via a separate thread. */
|
||||
static void restart_threads(void)
|
||||
{
|
||||
pthread_t rthread;
|
||||
|
||||
if (unlikely(pthread_create(&rthread, NULL, restart_thread, NULL)))
|
||||
quit(1, "Failed to create restart thread");
|
||||
}
|
||||
|
||||
static void signal_work_update(void)
|
||||
|
Loading…
Reference in New Issue
Block a user