ethereum-mining / ethminer

Ethereum miner with OpenCL, CUDA and stratum support
GNU General Public License v3.0
5.96k stars 2.28k forks source link

reduce mutex long time #1590

Closed DekInc closed 5 years ago

DekInc commented 5 years ago

Hi, i can't push code so, maybe this is a little bug, in miner.h

function setWork, the mutex is closed after other operations, i think maybe it's bettter like this:

void setWork(WorkPackage const& _work) { { Guard l(x_work); m_work = _work; }

StefanOberhumer commented 5 years ago

As parts of m_work adjusted after 'm_work = work;' (see https://github.com/ethereum-mining/ethminer/blob/ee701d2d9dc30c1a7df7df8bac5e0b0109360f41/libethcore/Miner.h#L333-L348) the scope of the guard must also contain these adjustments.

Perhaps https://github.com/ethereum-mining/ethminer/blob/ee701d2d9dc30c1a7df7df8bac5e0b0109360f41/libethcore/Miner.h#L350-L352 could be moved out of the lock scope but this is just included in special development builds.