| 3436 | bool IsFinalized() { return is_finalized_; } |
| 3437 | |
| 3438 | void Finalize(bool from_destructor = false) { |
| 3439 | if (is_finalized_.exchange(true)) { |
| 3440 | // Already finalized |
| 3441 | return; |
| 3442 | } |
| 3443 | if (is_initialized_.exchange(false)) { |
| 3444 | // Was initialized |
| 3445 | if (from_destructor) { |
| 3446 | ARROW_LOG(WARNING) |
| 3447 | << " arrow::fs::FinalizeS3 was not called even though S3 was initialized. " |
| 3448 | "This could lead to a segmentation fault at exit"; |
| 3449 | // Leak the S3ClientFinalizer to avoid crashes when destroying remaining |
| 3450 | // S3Client instances (GH-44071). |
| 3451 | auto* leaked_shared_ptr = |
| 3452 | new std::shared_ptr<S3ClientFinalizer>(GetClientFinalizer()); |
| 3453 | ARROW_UNUSED(leaked_shared_ptr); |
| 3454 | return; |
| 3455 | } |
| 3456 | GetClientFinalizer()->Finalize(); |
| 3457 | EndpointProviderCache::Instance()->Reset(); |
| 3458 | Aws::ShutdownAPI(aws_options_); |
| 3459 | } |
| 3460 | } |
| 3461 | |
| 3462 | private: |
| 3463 | void DoInitialize(const S3GlobalOptions& options) { |
nothing calls this directly
no test coverage detected