Fix a possible segmentation fault of ExpiryTimer.
authorcoderhyme <jhyo.kim@samsung.com>
Mon, 28 Sep 2015 07:49:29 +0000 (00:49 -0700)
committerMadan Lanka <lanka.madan@samsung.com>
Mon, 28 Sep 2015 13:52:50 +0000 (13:52 +0000)
The thread for ExpiryTimer might be started before members are initialized.

Change-Id: I2d83a60bb84422e033f6165aef3cb0136edbeae7
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3187
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
(cherry picked from commit 735bf9c001146666d86f5e744e3a0cce6a5aa860)
Reviewed-on: https://gerrit.iotivity.org/gerrit/3197

service/resource-encapsulation/src/common/expiryTimer/src/ExpiryTimerImpl.cpp

index f7ca6bd..c79d1e6 100644 (file)
@@ -34,13 +34,14 @@ namespace OIC
 
         ExpiryTimerImpl::ExpiryTimerImpl() :
                 m_tasks{ },
-                m_thread{ std::thread(&ExpiryTimerImpl::run, this) },
+                m_thread{ },
                 m_mutex{ },
                 m_cond{ },
                 m_stop{ false },
                 m_mt{ std::random_device{ }() },
                 m_dist{ }
         {
+            m_thread = std::thread(&ExpiryTimerImpl::run, this);
         }
 
         ExpiryTimerImpl::~ExpiryTimerImpl()