Skip to content

Commit

Permalink
Only unlock in branch where try_lock was successful
Browse files Browse the repository at this point in the history
Potential double mutex release issue.
  • Loading branch information
rob-p committed Aug 22, 2016
1 parent 594469d commit c7e60c8
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/SalmonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1922,18 +1922,19 @@ Eigen::VectorXd updateEffectiveLengths(SalmonOpts& sopt, ReadExpT& readExp,
} // end sequence-specific factor calculation

if (numProcessed > nextUpdate) {
updateMutex.try_lock();
if (numProcessed > nextUpdate) {
sopt.jointLog->info(
"processed bias for {:3.1f}% of the transcripts",
100.0 *
(numProcessed / static_cast<double>(numTranscripts)));
nextUpdate += stepSize;
if (nextUpdate > numTranscripts) {
nextUpdate = numTranscripts - 1;
if (updateMutex.try_lock()) {
if (numProcessed > nextUpdate) {
sopt.jointLog->info(
"processed bias for {:3.1f}% of the transcripts",
100.0 *
(numProcessed / static_cast<double>(numTranscripts)));
nextUpdate += stepSize;
if (nextUpdate > numTranscripts) {
nextUpdate = numTranscripts - 1;
}
}
updateMutex.unlock();
}
}
updateMutex.unlock();
}
++numProcessed;

Expand Down

0 comments on commit c7e60c8

Please sign in to comment.