Skip to content

Commit 4157d4b

Browse files
Fix segmentation fault in iot client init functions (#430)
* Fix segmentation fault in iot client init functions * Added slight delay to Jobs sample so the output is always printed to the terminal, even on fast machines
1 parent 1c457ab commit 4157d4b

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

identity/source/IotIdentityClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace Aws
2626
{
2727
}
2828

29-
IotIdentityClient::operator bool() const noexcept { return *m_connection; }
29+
IotIdentityClient::operator bool() const noexcept { return m_connection && *m_connection; }
3030

3131
int IotIdentityClient::GetLastError() const noexcept { return aws_last_error(); }
3232

jobs/source/IotJobsClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace Aws
3333
{
3434
}
3535

36-
IotJobsClient::operator bool() const noexcept { return *m_connection; }
36+
IotJobsClient::operator bool() const noexcept { return m_connection && *m_connection; }
3737

3838
int IotJobsClient::GetLastError() const noexcept { return aws_last_error(); }
3939

samples/jobs/describe_job_execution/main.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <aws/iotjobs/RejectedError.h>
1616

1717
#include <algorithm>
18+
#include <chrono>
1819
#include <condition_variable>
1920
#include <iostream>
2021
#include <mutex>
@@ -168,6 +169,9 @@ int main(int argc, char *argv[])
168169
publishDescribeJobExeCompletedPromise.get_future().wait();
169170
}
170171

172+
/* Wait just a little bit to let the console print */
173+
std::this_thread::sleep_for(std::chrono::milliseconds(500));
174+
171175
/* Disconnect */
172176
if (connection->Disconnect())
173177
{

secure_tunneling/source/IotSecureTunnelingClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace Aws
2929
{
3030
}
3131

32-
IotSecureTunnelingClient::operator bool() const noexcept { return *m_connection; }
32+
IotSecureTunnelingClient::operator bool() const noexcept { return m_connection && *m_connection; }
3333

3434
int IotSecureTunnelingClient::GetLastError() const noexcept { return aws_last_error(); }
3535

shadow/source/IotShadowClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace Aws
3838
{
3939
}
4040

41-
IotShadowClient::operator bool() const noexcept { return *m_connection; }
41+
IotShadowClient::operator bool() const noexcept { return m_connection && *m_connection; }
4242

4343
int IotShadowClient::GetLastError() const noexcept { return aws_last_error(); }
4444

0 commit comments

Comments
 (0)