Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a mutex owned by each port that protects its connections #283

Conversation

meyerj
Copy link
Member

@meyerj meyerj commented Apr 16, 2019

The connection_mutex owned by the port's ConnectionManager was only protecting its internal list of connections, but not the whole process of creating new connections, data objects or buffers. At least connections that involve shared buffers (#114) were subject to race conditions if multiple threads establish and disconnect connections concurrently.

The new port connection mutex is locked early inside the ConnFactory and inside ConnInputEndPoint and ConnInputEndPoint for the case port connection is disconnected from the remote end.

InputPortInterface::connected() and OutputPortInterface::connected() are forwarding to their respective ChannelElement endpoints, where the test can be done in lock-free way.

The ports_test has been updated to also cover errors during concurrent connection management.

Note that writing to and reading from ports with only lock-free connections (the default) is still expected to be a lock-free operation. Only adding or removing port connections involves locks (as it has been before for the mutex owned by the ConnectionManager).

The connection_mutex owned by the port's ConnectionManager was only protecting its
internal list of connections. At least connections that involve shared buffers
were subject to race conditions if multiple threads establish and disconnect
connections concurrently.

The new mutex is locked early inside the ConnFactory and inside ConnInputEndPoint
and ConnInputEndPoint for the case port connection is disconnected from the remote
end.

InputPortInterface::connected() and OutputPortInterface::connected() are forwarding
to their respective ChannelElement endpoints, where the test can be done in lock-free
way.

The ports_test has been updated to also cover errors during concurrent connection
management.

Signed-off-by: Johannes Meyer <johannes@intermodalics.eu>
@meyerj meyerj added this to the 2.10 milestone Apr 16, 2019
@meyerj meyerj merged commit 791c64e into updated-dataflow-semantics-rebased May 8, 2019
@meyerj meyerj deleted the toolchain-2.9-fix-concurrent-port-connections branch May 8, 2019 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant