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/PatchImpl.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/PatchImpl.cpp')
-rw-r--r-- | src/libs/engine/PatchImpl.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/libs/engine/PatchImpl.cpp b/src/libs/engine/PatchImpl.cpp index 1625d1c3..2d33dd0d 100644 --- a/src/libs/engine/PatchImpl.cpp +++ b/src/libs/engine/PatchImpl.cpp @@ -289,12 +289,12 @@ PatchImpl::remove_node(const string& name) /** Remove a connection. - * Process thread only. + * Preprocessing thread only. */ PatchImpl::Connections::Node* PatchImpl::remove_connection(const PortImpl* src_port, const PortImpl* dst_port) { - assert(ThreadManager::current_thread_id() == THREAD_PROCESS); + assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS); bool found = false; Connections::Node* connection = NULL; for (Connections::iterator i = _connections.begin(); i != _connections.end(); ++i) { @@ -311,6 +311,20 @@ PatchImpl::remove_connection(const PortImpl* src_port, const PortImpl* dst_port) return connection; } + + +bool +PatchImpl::has_connection(const PortImpl* src_port, const PortImpl* dst_port) const +{ + // FIXME: Doesn't scale + for (Connections::const_iterator i = _connections.begin(); i != _connections.end(); ++i) { + ConnectionImpl* const c = (ConnectionImpl*)i->get(); + if (c->src_port() == src_port && c->dst_port() == dst_port) + return true; + } + + return false; +} uint32_t |