tradecraftio / tradecraft

Tradecraft integration/staging tree https://tradecraft.io/download
Other
13 stars 9 forks source link

Daemon takes a long time to exit when stratum mining is used #99

Open maaku opened 2 years ago

maaku commented 2 years ago

When exiting the daemon, it can take a while (5-10 minutes, I haven't yet timed it) to actually terminate the program. Specifically I've noticed this in the bitcoin-merged-mining-23 branch, although it likely affects other versions and freicoin as well.

I think the bug is due to the fact that we wait for the stratum block notification watching thread to exit, and this thread won't exit until it it receives a notification of a new block. We probably need to check the logic in this thread's condition variable wait loop, and maybe provide a fake block notification to wake up that thread.

maaku commented 1 year ago

This has been fixed in the bitcoin-merge-mining-24 branch. Fix needs to be applied to the latest Freicoin branch as well. The problem was the notification thread as expected, but also holding any shared pointers to wallet instances on termination. These needed to be returned on shutdown or else there would be a deadlock in the wallet code.