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

Fix some memory leak cases in legacy code #498

Merged
merged 1 commit into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
80 changes: 42 additions & 38 deletions aws/kinesis/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,46 +361,50 @@ int main(int argc, char* const* argv) {
aws::utils::setup_aws_logging(options.aws_log_level);
Aws::SDKOptions sdk_options;
Aws::InitAPI(sdk_options);

if (options.enable_stack_trace) {
aws::utils::setup_stack_trace(argv[0]);
}

try {
auto config = get_config(options.configuration);

if (config->enable_core_dumps()) {
set_core_limit();
{
if (options.enable_stack_trace) {
aws::utils::setup_stack_trace(argv[0]);
}

aws::utils::set_log_level(config->log_level());

auto executor = get_executor();
auto region = get_region(*config);
auto creds_providers = get_creds_providers();
auto ipc_manager = get_ipc_manager(options.output_pipe, options.input_pipe);
auto ca_path = get_ca_path();
LOG(info) << "Starting up main producer";

aws::kinesis::core::KinesisProducer kp(
ipc_manager,
region,
config,
creds_providers.first,
creds_providers.second,
executor,
ca_path);

LOG(info) << "Entering join";

// Never returns
kp.join();
} catch (const std::exception& e) {
LOG(error) << e.what();
return 2;
} catch (int code) {
return code;
try {
auto config = get_config(options.configuration);

if (config->enable_core_dumps()) {
set_core_limit();
}

aws::utils::set_log_level(config->log_level());

auto executor = get_executor();
auto region = get_region(*config);
auto creds_providers = get_creds_providers();
auto ipc_manager = get_ipc_manager(options.output_pipe, options.input_pipe);
auto ca_path = get_ca_path();
LOG(info) << "Starting up main producer";

aws::kinesis::core::KinesisProducer kp(
ipc_manager,
region,
config,
creds_providers.first,
creds_providers.second,
executor,
ca_path);

LOG(info) << "Entering join";

// Never returns
kp.join();
} catch (const std::exception& e) {
LOG(error) << e.what();
return 2;
} catch (int code) {
return code;
}
}

aws::utils::teardown_aws_logging();
Aws::ShutdownAPI(sdk_options);
return 0;
}


4 changes: 4 additions & 0 deletions aws/utils/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,9 @@ void setup_aws_logging(Aws::Utils::Logging::LogLevel log_level) {
LOG(info) << "Set AWS Log Level to " << Aws::Utils::Logging::GetLogLevelName(log_level);
}

void teardown_aws_logging() {
Aws::Utils::Logging::ShutdownAWSLogging();
}

} //namespace utils
} //namespace aws
1 change: 1 addition & 0 deletions aws/utils/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void setup_logging(const std::string& min_level = "info");
void setup_logging(boost::log::trivial::severity_level level);

void setup_aws_logging(Aws::Utils::Logging::LogLevel log_level);
void teardown_aws_logging();

} //namespace utils
} //namespace aws
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ BOOST_VERSION_UNDERSCORED="${BOOST_VERSION//\./_}" # convert from 1.76.0 to 1_76
ZLIB_VERSION="1.2.13"
PROTOBUF_VERSION="3.11.4"
CURL_VERSION="7.86.0"
AWS_SDK_CPP_VERSION="1.11.59"
AWS_SDK_CPP_VERSION="1.11.62"

LIB_OPENSSL="https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz"
LIB_BOOST="https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_UNDERSCORED}.tar.gz"
Expand Down