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

KRPC-97 Race condition in stream cancellation locks the transport #138

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

Mr3zee
Copy link
Collaborator

@Mr3zee Mr3zee commented Jul 17, 2024

Subsystem
Stream cancellation

Problem Description
There might be a race condition between StreamEnd and StreamCancel messages, resulting in a deadlock in

public suspend fun cancelStream(message: RPCCallMessage.StreamCancel) {
    incomingChannelOf(message.streamId).send(StreamCancel(message.cause.deserialize()))
}

incomingChannelOf waits for the cannel that was already removed and will never be present

Solution
Added a closedStreams set that checks for such already closed streams and if on is closed - does not wait to close it once again

@Mr3zee Mr3zee requested a review from e5l July 17, 2024 09:43
@Mr3zee Mr3zee self-assigned this Jul 17, 2024
@Mr3zee Mr3zee force-pushed the KRPC-97-race-condition-on-cancellation branch from 886989e to 3ebe3c7 Compare July 22, 2024 12:31
@Mr3zee Mr3zee requested a review from e5l July 22, 2024 12:32
@Mr3zee Mr3zee merged commit 1110043 into main Jul 23, 2024
@Mr3zee Mr3zee deleted the KRPC-97-race-condition-on-cancellation branch July 26, 2024 09:03
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.

None yet

2 participants