Skip to content

Unblock connection receive when context is done#781

Merged
n3wscott merged 1 commit intocloudevents:mainfrom
igolaizola:bugfix/unblock-receive
Jul 18, 2022
Merged

Unblock connection receive when context is done#781
n3wscott merged 1 commit intocloudevents:mainfrom
igolaizola:bugfix/unblock-receive

Conversation

@igolaizola
Copy link
Copy Markdown
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>
@igolaizola igolaizola force-pushed the bugfix/unblock-receive branch from b03f795 to 4cec1cf Compare July 7, 2022 15:37
@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.

2 participants