Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock elimination for GetEstimatedTimetoStake() #1084

Merged
merged 1 commit into from
May 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@ void GetGlobalStatus()
sWeight = sWeight.substr(0,13) + "E" + RoundToString((double)sWeight.length()-13,0);
}

// It is necessary to assign a local variable for ETTS to avoid an occasional deadlock between the lock below,
// the lock on cs_main in GetEstimateTimetoStake(), and the corresponding lock in the stakeminer.
double dETTS = GetEstimatedTimetoStake()/86400.0;
LOCK(GlobalStatusStruct.lock);
{ LOCK(MinerStatus.lock);
GlobalStatusStruct.blocks = ToString(nBestHeight);
Expand All @@ -690,7 +693,7 @@ void GetGlobalStatus()
//todo: use the real weight from miner status (requires scaling)
GlobalStatusStruct.coinWeight = sWeight;
GlobalStatusStruct.magnitude = RoundToString(boincmagnitude,2);
GlobalStatusStruct.ETTS = RoundToString(GetEstimatedTimetoStake()/86400.0,3);
GlobalStatusStruct.ETTS = RoundToString(dETTS,3);
GlobalStatusStruct.ERRperday = RoundToString(boincmagnitude * GRCMagnitudeUnit(GetAdjustedTime()),2);
GlobalStatusStruct.project = msMiningProject;
GlobalStatusStruct.cpid = GlobalCPUMiningCPID.cpid;
Expand Down