pitrou commented on code in PR #47903:
URL: https://github.com/apache/arrow/pull/47903#discussion_r2477954211
##########
cpp/src/arrow/filesystem/s3fs.cc:
##########
@@ -3419,29 +3424,33 @@ struct AwsInstance {
// Returns true iff the instance was newly initialized with `options`
Result<bool> EnsureInitialized(const S3GlobalOptions& options) {
- // NOTE: The individual accesses are atomic but the entire sequence below
is not.
- // The application should serialize calls to InitializeS3() and
FinalizeS3()
- // (see docstrings).
- if (is_finalized_.load()) {
- return Status::Invalid("Attempt to initialize S3 after it has been
finalized");
- }
- bool newly_initialized = false;
// EnsureInitialized() can be called concurrently by FileSystemFromUri,
// therefore we need to serialize initialization (GH-39897).
- std::call_once(initialize_flag_, [&]() {
- bool was_initialized = is_initialized_.exchange(true);
- DCHECK(!was_initialized);
+ // We use a mutex instead of std::call_once to allow re-initialization
after
+ // finalization (as supported by the AWS SDK).
+ std::lock_guard<std::mutex> lock(init_mutex_);
+
+ if (!is_initialized_.load()) {
+ // Not already initialized, allow re-initialization after finalization
Review Comment:
Can we perhaps only allow it if the AWS SDK version is recent enough?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]