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

BearerTokenAuthenticationPolicy can be more efficient by utilizing shared/unique token locking #4756

Closed
antkmsft opened this issue Jul 6, 2023 · 0 comments · Fixed by #5188
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. feature-request This issue requires a new behavior in the product in order be resolved.

Comments

@antkmsft
Copy link
Member

antkmsft commented Jul 6, 2023

We can shared_lock when checking if the token has not expired, and then unique_lock when we know that we need to update the token, but just before updating (which sends network request), check for the second time in case another thread has just updated it.

include <shared_nutex> nut use shared_timed_mutex and not shared_mutex, because the first is C++14, while the other is C++17.

@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. needs-team-triage Workflow: This issue needs the team to triage. Storage Storage Service (Queues, Blobs, Files) labels Jul 6, 2023
@Jinming-Hu Jinming-Hu removed the Storage Storage Service (Queues, Blobs, Files) label Jul 11, 2023
@RickWinter RickWinter added feature-request This issue requires a new behavior in the product in order be resolved. Azure.Identity and removed needs-team-triage Workflow: This issue needs the team to triage. labels Jul 14, 2023
azure-sdk added a commit to azure-sdk/vcpkg that referenced this issue Jan 11, 2024
## 1.11.0 (2024-01-11)

### Features Added

- Added 'OPTIONS' HTTP method to `Azure::Core::Http::HttpMethod` enum.
- Added TLS 1.3 support to WinHTTP transport.
- Environment Log Level Listener now logs the ThreadID for the thread originating the trace.
- [[microsoft#4983]](Azure/azure-sdk-for-cpp#4983) Added support for setting `CURLOPT_CAPATH` libcurl option on Linux. (A community contribution, courtesy of _[phoebusm](https://github.com/phoebusm)_)

### Bugs Fixed

- [[microsoft#5172]](Azure/azure-sdk-for-cpp#5172) `Azure::Nullable::Emplace()` does not set `HasValue()` to `true`.
- [[microsoft#5130]](Azure/azure-sdk-for-cpp#5130) `Url::AppendPath()` and `Url::SetPath()` may end up with a double slash at the beginning of a path.
- [[microsoft#5007]](Azure/azure-sdk-for-cpp#5007) Some versions of GCC no longer include stdint.h in cstdint.

### Other Changes

- [[microsoft#4756]] (Azure/azure-sdk-for-cpp#4756) `BearerTokenAuthenticationPolicy` now uses shared mutex lock for read operations.

### Acknowledgments

Thank you to our developer community members who helped to make Azure Core better with their contributions to this release:

- Phoebus Mak _([GitHub](https://github.com/phoebusm))_
JavierMatosD pushed a commit to microsoft/vcpkg that referenced this issue Jan 12, 2024
* [azure-messaging-eventhubs-cpp] Update to 1.0.0-beta.5
## 1.0.0-beta.5 (2024-01-11)

### Breaking Changes

- EventHub `ConsumerClient` and `ProcessorClient` objects now return pointers to `EventData` objects instead of `EventData` objects by value.

* [azure-core-amqp-cpp] Update to 1.0.0-beta.6
## 1.0.0-beta.6 (2024-01-11)

### Features Added

- AMQP Value reference counts are now atomic, this fixes several AMQP related crashes.

### Breaking Changes

- `MessageReceiver` returns a pointer to the received message instead of a copy.

### Bugs Fixed

- Fixed several memory leaks.
- AMQP Link Credits now work as expected.
- Integrated the fix for NVD - CVE-2024-21646.

* [azure-core-cpp] Update to 1.11.0
## 1.11.0 (2024-01-11)

### Features Added

- Added 'OPTIONS' HTTP method to `Azure::Core::Http::HttpMethod` enum.
- Added TLS 1.3 support to WinHTTP transport.
- Environment Log Level Listener now logs the ThreadID for the thread originating the trace.
- [[#4983]](Azure/azure-sdk-for-cpp#4983) Added support for setting `CURLOPT_CAPATH` libcurl option on Linux. (A community contribution, courtesy of _[phoebusm](https://github.com/phoebusm)_)

### Bugs Fixed

- [[#5172]](Azure/azure-sdk-for-cpp#5172) `Azure::Nullable::Emplace()` does not set `HasValue()` to `true`.
- [[#5130]](Azure/azure-sdk-for-cpp#5130) `Url::AppendPath()` and `Url::SetPath()` may end up with a double slash at the beginning of a path.
- [[#5007]](Azure/azure-sdk-for-cpp#5007) Some versions of GCC no longer include stdint.h in cstdint.

### Other Changes

- [[#4756]] (Azure/azure-sdk-for-cpp#4756) `BearerTokenAuthenticationPolicy` now uses shared mutex lock for read operations.

### Acknowledgments

Thank you to our developer community members who helped to make Azure Core better with their contributions to this release:

- Phoebus Mak _([GitHub](https://github.com/phoebusm))_
Osyotr pushed a commit to Osyotr/vcpkg that referenced this issue Jan 23, 2024
* [azure-messaging-eventhubs-cpp] Update to 1.0.0-beta.5
## 1.0.0-beta.5 (2024-01-11)

### Breaking Changes

- EventHub `ConsumerClient` and `ProcessorClient` objects now return pointers to `EventData` objects instead of `EventData` objects by value.

* [azure-core-amqp-cpp] Update to 1.0.0-beta.6
## 1.0.0-beta.6 (2024-01-11)

### Features Added

- AMQP Value reference counts are now atomic, this fixes several AMQP related crashes.

### Breaking Changes

- `MessageReceiver` returns a pointer to the received message instead of a copy.

### Bugs Fixed

- Fixed several memory leaks.
- AMQP Link Credits now work as expected.
- Integrated the fix for NVD - CVE-2024-21646.

* [azure-core-cpp] Update to 1.11.0
## 1.11.0 (2024-01-11)

### Features Added

- Added 'OPTIONS' HTTP method to `Azure::Core::Http::HttpMethod` enum.
- Added TLS 1.3 support to WinHTTP transport.
- Environment Log Level Listener now logs the ThreadID for the thread originating the trace.
- [[microsoft#4983]](Azure/azure-sdk-for-cpp#4983) Added support for setting `CURLOPT_CAPATH` libcurl option on Linux. (A community contribution, courtesy of _[phoebusm](https://github.com/phoebusm)_)

### Bugs Fixed

- [[microsoft#5172]](Azure/azure-sdk-for-cpp#5172) `Azure::Nullable::Emplace()` does not set `HasValue()` to `true`.
- [[microsoft#5130]](Azure/azure-sdk-for-cpp#5130) `Url::AppendPath()` and `Url::SetPath()` may end up with a double slash at the beginning of a path.
- [[microsoft#5007]](Azure/azure-sdk-for-cpp#5007) Some versions of GCC no longer include stdint.h in cstdint.

### Other Changes

- [[microsoft#4756]] (Azure/azure-sdk-for-cpp#4756) `BearerTokenAuthenticationPolicy` now uses shared mutex lock for read operations.

### Acknowledgments

Thank you to our developer community members who helped to make Azure Core better with their contributions to this release:

- Phoebus Mak _([GitHub](https://github.com/phoebusm))_
TomKatom pushed a commit to TomKatom/vcpkg that referenced this issue Feb 23, 2024
* [azure-messaging-eventhubs-cpp] Update to 1.0.0-beta.5
## 1.0.0-beta.5 (2024-01-11)

### Breaking Changes

- EventHub `ConsumerClient` and `ProcessorClient` objects now return pointers to `EventData` objects instead of `EventData` objects by value.

* [azure-core-amqp-cpp] Update to 1.0.0-beta.6
## 1.0.0-beta.6 (2024-01-11)

### Features Added

- AMQP Value reference counts are now atomic, this fixes several AMQP related crashes.

### Breaking Changes

- `MessageReceiver` returns a pointer to the received message instead of a copy.

### Bugs Fixed

- Fixed several memory leaks.
- AMQP Link Credits now work as expected.
- Integrated the fix for NVD - CVE-2024-21646.

* [azure-core-cpp] Update to 1.11.0
## 1.11.0 (2024-01-11)

### Features Added

- Added 'OPTIONS' HTTP method to `Azure::Core::Http::HttpMethod` enum.
- Added TLS 1.3 support to WinHTTP transport.
- Environment Log Level Listener now logs the ThreadID for the thread originating the trace.
- [[microsoft#4983]](Azure/azure-sdk-for-cpp#4983) Added support for setting `CURLOPT_CAPATH` libcurl option on Linux. (A community contribution, courtesy of _[phoebusm](https://github.com/phoebusm)_)

### Bugs Fixed

- [[microsoft#5172]](Azure/azure-sdk-for-cpp#5172) `Azure::Nullable::Emplace()` does not set `HasValue()` to `true`.
- [[microsoft#5130]](Azure/azure-sdk-for-cpp#5130) `Url::AppendPath()` and `Url::SetPath()` may end up with a double slash at the beginning of a path.
- [[microsoft#5007]](Azure/azure-sdk-for-cpp#5007) Some versions of GCC no longer include stdint.h in cstdint.

### Other Changes

- [[microsoft#4756]] (Azure/azure-sdk-for-cpp#4756) `BearerTokenAuthenticationPolicy` now uses shared mutex lock for read operations.

### Acknowledgments

Thank you to our developer community members who helped to make Azure Core better with their contributions to this release:

- Phoebus Mak _([GitHub](https://github.com/phoebusm))_
@github-actions github-actions bot locked and limited conversation to collaborators Feb 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. feature-request This issue requires a new behavior in the product in order be resolved.
Projects
3 participants