Skip to content

Commit

Permalink
GH-36346: [C++] Safe S3 finalization (#36442)
Browse files Browse the repository at this point in the history
### Rationale for this change

It is required to call `FinalizeS3` at process end to cleanly shut down resources used by the AWS SDK before it's too late.
However, once `FinalizeS3` has been called, another problem appears: no AWS SDK API can be called safely anymore. Even object destructors can be dangerous.
We therefore need a way to prevent unsafe use of the AWS SDK APIs, regardless of how the application issues filesystems calls.

### What changes are included in this PR?

Shield all uses of the internal `S3Client` class behind a safe RAII facility `S3ClientLock`. Obtaining a `S3ClientLock` ensures that S3 finalization has not been called yet _and_ that it will not be called until the `S3ClientLock` goes out of scope.

### Are these changes tested?

Yes, some Python tests exercise calling S3 APIs after explicit finalization.

### Are there any user-facing changes?

Not for correctly written application code, ideally.

* Closes: #36346

Authored-by: Antoine Pitrou <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
  • Loading branch information
pitrou authored Jul 4, 2023
1 parent cd1ed18 commit e7d5028
Show file tree
Hide file tree
Showing 5 changed files with 393 additions and 114 deletions.
Loading

0 comments on commit e7d5028

Please sign in to comment.