Skip to content

Commit

Permalink
PR updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bretambrose committed Oct 31, 2024
1 parent 4d9097a commit 44f6a06
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 15 additions & 0 deletions source/iot/MqttRequestResponseClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ namespace Aws
namespace RequestResponse
{

/*
* RAII wrapper around taking a read lock for a referenced read-write lock.
*
* Used to protect the stream from destruction while in a callback or Open() call. Protects the
* m_closed field of StreamingOperationImpl.
*/
class StreamReadLock
{
public:
Expand All @@ -29,6 +35,15 @@ namespace Aws
struct aws_rw_lock *m_lock;
};

/*
* RAII wrapper around taking a *conditional* write lock for a referenced read-write lock. Protects the
* m_closed field of StreamingOperationImpl.
*
* Used to block callbacks while destruction is triggered. Only ever used by the stream destructor.
* We conditionally take the lock because if we're already in the event loop thread we're safe and we
* are probably (but not guaranteed to be) in a callback. This prevents deadlock from trying to upgrade
* an already taken read lock to a write lock, which is not supported by the underlying read-write lock.
*/
class StreamWriteLock
{
public:
Expand Down
7 changes: 4 additions & 3 deletions tests/MqttRequestResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,24 @@ static TestContext s_CreateClient(
Aws::Iot::RequestResponse::RequestResponseClientOptions *options = NULL)
{
TestContext context;
Aws::Iot::RequestResponse::RequestResponseClientOptions finalOptions;

Aws::Iot::RequestResponse::RequestResponseClientOptions finalOptions;
struct aws_string *host = NULL;
struct aws_string *certificatePath = NULL;
struct aws_string *privateKeyPath = NULL;

if (aws_get_environment_value(allocator, s_rrEnvVariableHost, &host))
if (aws_get_environment_value(allocator, s_rrEnvVariableHost, &host) || !host)
{
goto done;
}

if (aws_get_environment_value(allocator, s_rrEnvVariableCertificatePath, &certificatePath))
if (aws_get_environment_value(allocator, s_rrEnvVariableCertificatePath, &certificatePath) || !certificatePath)
{
goto done;
}

if (aws_get_environment_value(allocator, s_rrEnvVariablePrivateKeyPath, &privateKeyPath))
if (aws_get_environment_value(allocator, s_rrEnvVariablePrivateKeyPath, &privateKeyPath) || !privateKeyPath)
{
goto done;
}
Expand Down

0 comments on commit 44f6a06

Please sign in to comment.