fix a deadlock with jack2 when inserting a plugin adds ports.
authorRobin Gareus <robin@gareus.org>
Thu, 28 Apr 2016 19:15:26 +0000 (21:15 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 28 Apr 2016 19:15:26 +0000 (21:15 +0200)
commit633f2189111be18cb03fe847707b0f598e453abe
tree87f4211ed7027b8ec9983b2b01fc5480c8633180
parentd81547efb4e70c51d993e43aff99aa0585ed7f6e
fix a deadlock with jack2 when inserting a plugin adds ports.

When adding a processor, the processor may add ports leading to
a call to jack_port_register(). while Ardour holds a WritertLock on the
processor-list (this commit removes this WriterLock).

with jack2 that results in a graph-reorder callback (WHY?)

jack2 issues that graph-reorder in a separate thread BUT
port-registration does not return until the graph-reorder is complete.

On Ardour's side, graph_reordered() calls Session::resort_routes ()
which eventually checks Route::direct_feeds_according_to_reality()
which needs a ReadLock on the processor-list to check I/O.

Since jack_port_register() does not return, this constitutes a deadlock.

THE ACTUAL PROBLEM IS JACK2's THREAD DESIGN!
Why does jack_port_register() trigger a graph-order in jack2?
No connections are made.
..and why does it block jack_port_register() from returning if
that graph-order callback is in a different thread?
http://pastebin.com/DZANXJLz
libs/ardour/ardour/route.h
libs/ardour/route.cc