close
Skip to content

Fix a race condition in unique_path. - #15

Merged
Beman merged 1 commit into
boostorg:developfrom
CornedBee:develop
Aug 28, 2015
Merged

Fix a race condition in unique_path.#15
Beman merged 1 commit into
boostorg:developfrom
CornedBee:develop

Conversation

@CornedBee

Copy link
Copy Markdown

If two threads call unique_path at the same time for the first time in the program run,
both initial calls to CryptAcquireContext can fail. Both threads will then call the function
with CRYPT_NEWKEYSET, but only one of these threads can succeed. The other will
fail with NTE_EXISTS.

This patch makes it so that if a call fails with that error, it will try to call without the
flag one more time, in case another thread created the key set in the meantime.

This also applies the patch from trac report #7506. Using these additional flags
is the right thing to do.

If two threads call unique_path at the same time for the first time in the program run,
both initial calls to CryptAcquireContext can fail. Both threads will then call the function
with CRYPT_NEWKEYSET, but only one of these threads can succeed. The other will
fail with NTE_EXISTS.

This patch makes it so that if a call fails with that error, it will try to call without the
flag one more time, in case another thread created the key set in the meantime.

This also applies the patch from trac report #7506. Using these additional flags
is the right thing to do.
Beman added a commit that referenced this pull request Aug 28, 2015
Fix a race condition in unique_path.
@Beman
Beman merged commit 1c90f5d into boostorg:develop Aug 28, 2015
@Beman

Beman commented Aug 28, 2015

Copy link
Copy Markdown
Contributor

Thanks, Sebastian,

--Beman

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