diff options
author | David Robillard <d@drobilla.net> | 2008-08-13 23:12:52 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-08-13 23:12:52 +0000 |
commit | ef22788409473e8fbc04b41c90027bbd7f34a9df (patch) | |
tree | 1e12db1e7eeb473d8678fb8f7b47a7d52af4c58d /src/libs/engine/events/ConnectionEvent.cpp | |
parent | 6d9179c30b56bb7be97e702951c393727d96cf05 (diff) | |
download | ingen-ef22788409473e8fbc04b41c90027bbd7f34a9df.tar.gz ingen-ef22788409473e8fbc04b41c90027bbd7f34a9df.tar.bz2 ingen-ef22788409473e8fbc04b41c90027bbd7f34a9df.zip |
Fix race condition resulting in duplicate connections if several identical requests come in rapid succession.
git-svn-id: http://svn.drobilla.net/lad/ingen@1359 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/events/ConnectionEvent.cpp')
-rw-r--r-- | src/libs/engine/events/ConnectionEvent.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp index 893dc9cb..ac04d1cc 100644 --- a/src/libs/engine/events/ConnectionEvent.cpp +++ b/src/libs/engine/events/ConnectionEvent.cpp @@ -88,12 +88,6 @@ ConnectionEvent::pre_process() return; } - if (_dst_input_port->is_connected_to(_src_output_port)) { - _error = ALREADY_CONNECTED; - QueuedEvent::pre_process(); - return; - } - NodeImpl* const src_node = _src_port->parent_node(); NodeImpl* const dst_node = _dst_port->parent_node(); @@ -116,6 +110,13 @@ ConnectionEvent::pre_process() } assert(_patch); + + //if (_dst_input_port->is_connected_to(_src_output_port)) { + if (_patch->has_connection(_src_output_port, _dst_input_port)) { + _error = ALREADY_CONNECTED; + QueuedEvent::pre_process(); + return; + } if (src_node == NULL || dst_node == NULL) { _error = PARENTS_NOT_FOUND; @@ -139,6 +140,8 @@ ConnectionEvent::pre_process() dst_node->providers()->push_back(new Raul::List<NodeImpl*>::Node(src_node)); src_node->dependants()->push_back(new Raul::List<NodeImpl*>::Node(dst_node)); } + + _patch->add_connection(_patch_listnode); if (_patch->enabled()) _compiled_patch = _patch->compile(); @@ -153,9 +156,8 @@ ConnectionEvent::execute(ProcessContext& context) QueuedEvent::execute(context); if (_error == NO_ERROR) { - // These must be inserted here, since they're actually used by the audio thread + // This must be inserted here, since they're actually used by the audio thread _dst_input_port->add_connection(_port_listnode); - _patch->add_connection(_patch_listnode); if (_patch->compiled_patch() != NULL) _engine.maid()->push(_patch->compiled_patch()); _patch->compiled_patch(_compiled_patch); |