mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 03:13:49 +00:00
avoid deadlock by nested waiting for mark passings collections monitor while holding a read lock on the course
This commit is contained in:
1 parent
a6b1b36ab7
commit
4e84ea63e2
1 file changed
+3
-1
+3
-1
@@ -1691,11 +1691,13 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
|||||||
boolean markPassingsNotEmpty;
|
boolean markPassingsNotEmpty;
|
||||||
TimePoint extendedFrom = null;
|
TimePoint extendedFrom = null;
|
||||||
MarkPassing crossedFinishLine = null;
|
MarkPassing crossedFinishLine = null;
|
||||||
|
// getLastWaypoint() will wait for a read lock on the course; do this outside the synchronized block to avoid deadlocks
|
||||||
|
final Waypoint lastWaypoint = getRace().getCourse().getLastWaypoint();
|
||||||
synchronized (markPassings) {
|
synchronized (markPassings) {
|
||||||
markPassingsNotEmpty = markPassings != null && !markPassings.isEmpty();
|
markPassingsNotEmpty = markPassings != null && !markPassings.isEmpty();
|
||||||
if (markPassingsNotEmpty) {
|
if (markPassingsNotEmpty) {
|
||||||
extendedFrom = markPassings.iterator().next().getTimePoint();
|
extendedFrom = markPassings.iterator().next().getTimePoint();
|
||||||
crossedFinishLine = getMarkPassing(competitor, getRace().getCourse().getLastWaypoint());
|
crossedFinishLine = getMarkPassing(competitor, lastWaypoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (markPassingsNotEmpty) {
|
if (markPassingsNotEmpty) {
|
||||||
|
|||||||
Reference in new issue
Block a user