backlog: fix potential deadlock in a different way #1014
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current implementation works insofar as that there is no deadlock, but unfortunately the
entries
data can become corrupted enough for the program to crash in the C++ stdlib.For the new solution we use a shared_timed_mutex, allowing shared read access to
entries
, and only acquire a unique lock for writing. Since this can run into a deadlock if an error happens during rendering of the backlog itself, we only wait 33ms to acquire it (1 frame @ 30 fps).If we can't get it by that time, we still write to debug output, but not into
entries
.The shared_timed_mutex also allows us to wait for a read lock at the end of the program, so we now wait for 1s instead of giving up immediately.
This commit also fixes a missing synchronization when accessing
history
that was accidentially removed.