Skip to content

Check cancellation token at start of WaitAsync() - #2507

Merged
roji merged 1 commit into
npgsql:hotfix/4.0.8from
roji:WaitAsyncCancelledToken
Jun 29, 2019
Merged

roji merged 1 commit into
npgsql:hotfix/4.0.8from
roji:WaitAsyncCancelledToken

Conversation

@roji

@roji roji commented Jun 26, 2019

Copy link
Copy Markdown
Member

Otherwise passing a cancelled token makes WaitAsync() crash.

Note that a race condition still exists if the token is cancelled after our check but before WaitAsync starts its job.

Fixes #2506

The fix for dev will be part of #2443

@roji
roji force-pushed the WaitAsyncCancelledToken branch from eaf8c9d to 64890bd Compare June 26, 2019 17:27

@YohDeadfall YohDeadfall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Comment thread src/Npgsql/NpgsqlConnector.cs Resolved
Comment thread src/Npgsql/NpgsqlConnection.cs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should Task.FromCanceled(cancellationToken) be used here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately it doesn't exist in net45 which is targeted in Npgsql 4.0... The equivalent for dev is using Task.FromCanceled() (#2443).

Otherwise passing a cancelled token makes WaitAsync() crash.
Note that a race condition still exists if the token is cancelled
after our check but before WaitAsync starts its job.

Fixes npgsql#2506
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