aws-sdk-cpp
aws-sdk-cpp copied to clipboard
Reference counting of `InitAPI`
Describe the feature
Provide a mechanism to prevent the sdk from breaking when InitAPI gets called when it has already been initialized.
Related issues/discussions:
- https://github.com/aws/aws-sdk-cpp/discussions/2406
- https://github.com/aws/aws-sdk-cpp/issues/456
Use Case
If code is being used in a library then there is currently no way for the library to know if InitAPI has already been called.
Proposed Solution
This will not/should not be RAII.
Using locks and reference counting this would allow multiple calls of InitAPI. Changes need to be make on this sdk and with the CRT
Other Information
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue, please leave a comment
Acknowledgements
- [ ] I may be able to implement this feature request
- [X] This feature might incur a breaking change
Just to clearify this for me: Calling InitAPI multiple times on a machine is okay as long as you don't do it inside the same application? Or has such a reference count to be system wide?
Just to clearify this for me: Calling InitAPI multiple times on a machine is okay as long as you don't do it inside the same application? Or has such a reference count to be system wide?
Yes, that should be fine as long as the programs aren't sharing memory
You can also handle the error result when it is already initialized, and ignore it.
https://github.com/aws/aws-sdk-cpp/commit/03036e49beca1b933b834c355459c8d182b00931
Does anyone know why #2699 triggers only on MacOS? We see this only on MacOS, not Linux, and I'd like to understand what's Mac-specific here ...
Does anyone know why https://github.com/aws/aws-sdk-cpp/issues/2699 triggers only on MacOS? We see this only on MacOS, not Linux, and I'd like to understand what's Mac-specific here ...
The issue linked is about the case when the Client outlives the InitAPI{}ShutdownAPI scope. This is a case of not following SDK basic-use documentation, however, I agree that the SDK API is not friendly, that's why, to prevent such kind of error, a client lifetime check has been added in https://github.com/aws/aws-sdk-cpp/pull/2515
The reason was failnig only on mac is due to the nature of undefined behavior, it may be different between different platforms and compilers.
Anyway, this issue is prevented from happening from different angles now.
Count of InitAPI / ShutdownAPI calls has been added back in https://github.com/aws/aws-sdk-cpp/pull/2710 Thank you.
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.