Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools-2680 tools-2681 backup service changes #68

Merged
merged 6 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/s3_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class S3API {

void Shutdown();

bool IsInitialized() const;
bool IsInitialized();

// This must be called before TryInitialize()
S3API& SetRegion(const std::string& region);
Expand Down Expand Up @@ -123,6 +123,7 @@ class S3API {
private:
std::once_flag init_once;
bool initialized;
std::mutex s3_init_lock;
Aws::SDKOptions options;

std::string region;
Expand Down
8 changes: 4 additions & 4 deletions src/restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ restore_main(int32_t argc, char **argv)
goto cleanup;
}

signal(SIGINT, sig_hand);
signal(SIGTERM, sig_hand);

restore_status_t *status = start_restore(&conf);
if (status != RUN_RESTORE_FAILURE) {
restore_status_destroy(status);
Expand Down Expand Up @@ -155,14 +158,11 @@ start_restore(restore_config_t *conf)

set_s3_configs(conf);

g_status = status;
if (!restore_status_init(status, conf)) {
err("Failed to initialize restore status");
goto cleanup1;
}

signal(SIGINT, sig_hand);
signal(SIGTERM, sig_hand);
g_status = status;

if (conf->validate) {
inf("Starting validation of %s",
Expand Down
17 changes: 14 additions & 3 deletions src/s3_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,38 @@ S3API::S3API() : initialized(false),
bool
S3API::TryInitialize()
{
std::call_once(init_once, _init_api, std::ref(*this));
if(initialized) {
return initialized;
}
dwelch-spike marked this conversation as resolved.
Show resolved Hide resolved

return this->initialized;
std::unique_lock<std::mutex> lg(s3_init_lock);
if(!initialized) {
_init_api(std::ref(*this));
}
lg.unlock();

return initialized;
}

void
S3API::Shutdown()
{
std::unique_lock<std::mutex> lg(s3_init_lock);
if (initialized) {
inf("Closing S3 API");
if (client != nullptr) {
delete client;
}

Aws::ShutdownAPI(options);
initialized = false;
}
}

bool
S3API::IsInitialized() const
S3API::IsInitialized()
{
std::unique_lock<std::mutex> lg(s3_init_lock);
return initialized;
}

Expand Down
Loading