summaryrefslogtreecommitdiff
path: root/libs/ardour/session.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2018-10-25 02:00:08 +0200
committerRobin Gareus <robin@gareus.org>2018-10-25 02:00:08 +0200
commit5599cdb911a9bbbd3f3f82a5d71ac7a850cb2d08 (patch)
tree767e01a5f262d9c643881c8f3d5b5d33ea7f8ea0 /libs/ardour/session.cc
parentd53f49acf463dc77883a5b562feaeb4f0ef5009f (diff)
Fix race-condition/deadlock, plugin-copy while rolling
lili93's session (#ardour) triggered this w/jackd 512fpp: Drag/Drop copy a latent plugin from one track to another while rolling. The GUI-thread as well as the auto-connect thread concurrently call jack_recompute_total_latencies(). The auto-connect thread holds a process lock while doing so. The GUI does not use any mutexes. This randomly deadlocks in libjack. backtrace: https://pastebin.com/6m3KGhWS
Diffstat (limited to 'libs/ardour/session.cc')
-rw-r--r--libs/ardour/session.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 228c52ef08..da4421d4a2 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -6944,6 +6944,17 @@ Session::update_latency_compensation (bool force_whole_graph)
if (_state_of_the_state & (InitialConnecting|Deletion)) {
return;
}
+ /* this lock is not usually contended, but under certain conditions,
+ * update_latency_compensation may be called concurrently.
+ * e.g. drag/drop copy a latent plugin while rolling.
+ * GUI thread (via route_processors_changed) and
+ * auto_connect_thread_run may race.
+ */
+ Glib::Threads::Mutex::Lock lx (_update_latency_lock, Glib::Threads::TRY_LOCK);
+ if (!lx.locked()) {
+ /* no need to do this twice */
+ return;
+ }
bool some_track_latency_changed = update_route_latency (false, false);