Fixed IOT-679
authorOmkar Hegde <omkar.m.hegde@intel.com>
Wed, 12 Aug 2015 16:51:31 +0000 (09:51 -0700)
committerErich Keane <erich.keane@intel.com>
Thu, 13 Aug 2015 16:59:15 +0000 (16:59 +0000)
Sometimes the server sends a observe notification before observe
cancel is processed by the client causing a segmentation fault.
Changing client to call cancel observe when count is equal to 11.

Change-Id: I2373a5bbadf0d3046e0f83af961528c19ab495d8
Signed-off-by: Omkar Hegde <omkar.m.hegde@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2191
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/examples/simpleclient.cpp
resource/examples/simpleclientHQ.cpp

index 7106d9e..b19f521 100644 (file)
@@ -85,7 +85,7 @@ void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
             std::cout << "\tpower: " << mylight.m_power << std::endl;
             std::cout << "\tname: " << mylight.m_name << std::endl;
 
-            if(observe_count() > 10)
+            if(observe_count() == 11)
             {
                 std::cout<<"Cancelling Observe..."<<std::endl;
                 OCStackResult result = curResource->cancelObserve();
index 5e69f01..61f8a92 100644 (file)
@@ -97,7 +97,7 @@ void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
         std::cout << "\tpower: " << mylight.m_power << std::endl;
         std::cout << "\tname: " << mylight.m_name << std::endl;
 
-        if(observe_count() > 10)
+        if(observe_count() == 11)
         {
             std::cout<<"Cancelling Observe..."<<std::endl;
             OCStackResult result = curResource->cancelObserve(OC::QualityOfService::HighQos);