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

Unblock connection receive when context is done #781

Merged
merged 1 commit into from Jul 18, 2022

Conversation

igolaizola
Copy link
Contributor

When context is canceled we don't read anymore from t.incoming channel
because the select clause exists on ctx.Done. This change adds the
same behavior to the point where t.incoming channel is written.
Without this the call to conn.Receive could block forever given a
race condition between a context cancellation and a new incoming
message.

Furthermore, is always a good practice to listen to context.Done on
blocking points where a context variable is available.

@igolaizola igolaizola force-pushed the bugfix/unblock-receive branch 3 times, most recently from a93c929 to b03f795 Compare July 7, 2022 15:22
When context is canceled we don't read anymore from `t.incoming` channel
because the select clause exists on `ctx.Done`. This change adds the
same behavior to the point where `t.incoming` channel is written.
Without this the call to `conn.Receive` could block forever given a
race condition between a context cancellation and a new incoming
message.

Furthermore, is always a good practice to listen to `context.Done` on
blocking points where a context variable is available.

Signed-off-by: Iñigo Garcia Olaizola <11333576+igolaizola@users.noreply.github.com>
@n3wscott n3wscott merged commit 0911e5f into cloudevents:main Jul 18, 2022
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