| 3503 | bool IsFinalized() { return is_finalized_; } |
| 3504 | |
| 3505 | void Finalize(bool from_destructor = false) { |
| 3506 | if (is_finalized_.exchange(true)) { |
| 3507 | // Already finalized |
| 3508 | return; |
| 3509 | } |
| 3510 | if (is_initialized_.exchange(false)) { |
| 3511 | // Was initialized |
| 3512 | if (from_destructor) { |
| 3513 | ARROW_LOG(WARNING) |
| 3514 | << " arrow::fs::FinalizeS3 was not called even though S3 was initialized. " |
| 3515 | "This could lead to a segmentation fault at exit"; |
| 3516 | // Leak the S3ClientFinalizer to avoid crashes when destroying remaining |
| 3517 | // S3Client instances (GH-44071). |
| 3518 | auto* leaked_shared_ptr = |
| 3519 | new std::shared_ptr<S3ClientFinalizer>(GetClientFinalizer()); |
| 3520 | ARROW_UNUSED(leaked_shared_ptr); |
| 3521 | return; |
| 3522 | } |
| 3523 | GetClientFinalizer()->Finalize(); |
| 3524 | EndpointProviderCache::Instance()->Reset(); |
| 3525 | Aws::ShutdownAPI(aws_options_); |
| 3526 | } |
| 3527 | } |
| 3528 | |
| 3529 | private: |
| 3530 | void DoInitialize(const S3GlobalOptions& options) { |
nothing calls this directly
no test coverage detected