From 0eaff88912def112caa9f0a1e9b656c436ecd156 Mon Sep 17 00:00:00 2001 From: Jeffery Wilson Date: Thu, 8 Aug 2024 15:32:40 -0400 Subject: [PATCH 1/2] add some logging --- src/gstawsapihandle.cpp | 1 + src/gstawscredentials.cpp | 6 +++++- src/gsts3sink.c | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gstawsapihandle.cpp b/src/gstawsapihandle.cpp index 0499f6e..69283fc 100644 --- a/src/gstawsapihandle.cpp +++ b/src/gstawsapihandle.cpp @@ -93,6 +93,7 @@ class Logger : public ::Aws::Utils::Logging::LogSystemInterface using gst::aws::AwsApiHandle; AwsApiHandle::AwsApiHandle() { + GST_CAT_DEBUG (gst_aws_s3_debug, "Initializing AWS API"); ::Aws::Utils::Logging::InitializeAWSLogging(::std::make_shared()); ::Aws::SDKOptions options; ::Aws::InitAPI(options); diff --git a/src/gstawscredentials.cpp b/src/gstawscredentials.cpp index c1f04a7..8b703be 100644 --- a/src/gstawscredentials.cpp +++ b/src/gstawscredentials.cpp @@ -111,10 +111,12 @@ _gst_aws_credentials_create_provider(const gchar * access_key_id, const gchar * GST_ERROR ("Either both access-key-id and secret-access-key must be set or none of them."); return NULL; } + GST_DEBUG ("Using default AWS credentials provider chain"); return std::unique_ptr (new DefaultAWSCredentialsProviderChain()); } else { + GST_DEBUG ("Using simple AWS credentials provider"); return std::unique_ptr ( new SimpleAWSCredentialsProvider (AWSCredentials(access_key_id, secret_access_key, session_token ? session_token : ""))); } @@ -160,8 +162,10 @@ _gst_aws_credentials_provider_from_string(const gchar * str) return NULL; } - if (!is_null_or_empty (iam_role)) + if (!is_null_or_empty (iam_role)) { + GST_DEBUG ("Assuming role '%s'", iam_role); provider = _gst_aws_credentials_assume_role(iam_role, std::move(provider)); + } g_strfreev (parameters); diff --git a/src/gsts3sink.c b/src/gsts3sink.c index 9291052..75dd277 100644 --- a/src/gsts3sink.c +++ b/src/gsts3sink.c @@ -416,6 +416,7 @@ gst_s3_sink_set_property (GObject * object, guint prop_id, case PROP_CREDENTIALS: if (sink->config.credentials) gst_aws_credentials_free (sink->config.credentials); + GST_DEBUG ("Setting AWS credentials"); sink->config.credentials = gst_aws_credentials_copy (g_value_get_boxed (value)); break; case PROP_AWS_SDK_ENDPOINT: @@ -533,8 +534,10 @@ gst_s3_sink_start (GstBaseSink * basesink) || gst_s3_sink_is_null_or_empty (sink->config.key))) goto no_destination; - if (!sink->config.credentials) + if (!sink->config.credentials) { + GST_DEBUG ("Using default AWS credentials"); sink->config.credentials = gst_aws_credentials_new_default (); + } if (sink->uploader == NULL) { sink->uploader = GST_S3_SINK_GET_CLASS((gpointer*) sink)->uploader_new (&sink->config); From 8664de51c150d6e0910b3a11c435dec5f398a00a Mon Sep 17 00:00:00 2001 From: Jeffery Wilson Date: Thu, 8 Aug 2024 16:35:04 -0400 Subject: [PATCH 2/2] api handle: make GetHandle() thread safe --- src/gstawsapihandle.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gstawsapihandle.cpp b/src/gstawsapihandle.cpp index 69283fc..3aefb11 100644 --- a/src/gstawsapihandle.cpp +++ b/src/gstawsapihandle.cpp @@ -109,6 +109,9 @@ AwsApiHandle::~AwsApiHandle() ::std::shared_ptr AwsApiHandle::GetHandle() { static ::std::weak_ptr instance; + static ::std::mutex mutex; + + const ::std::lock_guard<::std::mutex> lock(mutex); if (auto ptr = instance.lock()) { return ptr; }