From dd63de543da23f0a1e22cf15ec755c7f4652c001 Mon Sep 17 00:00:00 2001 From: HyunJun Kim Date: Fri, 23 Jan 2015 14:00:54 +0900 Subject: [PATCH] Fix FindGroup API of Things Manager about group sync feature. It is not notify about state of finding to caller. So we will return 'OC_STACK_ERROR' when It was finding a group. User should be wait findCallback. Then user will know the result of finding. FindCallback has the argument which OCResource. If it is NULL we could not find a group. Fix [IOT-286] Change-Id: I2b95d5102e54e4242394c36d51de81f192b87e13 Signed-off-by: HyunJun Kim Reviewed-on: https://gerrit.iotivity.org/gerrit/230 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- service/things-manager/sdk/src/GroupSynchronization.cpp | 7 +++++++ service/things-manager/sdk/src/GroupSynchronization.h | 1 + 2 files changed, 8 insertions(+) diff --git a/service/things-manager/sdk/src/GroupSynchronization.cpp b/service/things-manager/sdk/src/GroupSynchronization.cpp index 2b476b5..4210a00 100644 --- a/service/things-manager/sdk/src/GroupSynchronization.cpp +++ b/service/things-manager/sdk/src/GroupSynchronization.cpp @@ -29,6 +29,7 @@ namespace OIC { GroupSynchronization* GroupSynchronization::groupSyncnstance = NULL; + bool GroupSynchronization::bIsFinding = false; GroupSynchronization* GroupSynchronization::getInstance() { @@ -53,6 +54,9 @@ namespace OIC { cout << "GroupSynchronization::findGroup" << endl; + if(bIsFinding) + return OC_STACK_ERROR; + foundGroupResourceList.clear(); findCallback = callback; @@ -71,6 +75,8 @@ namespace OIC std::bind(&GroupSynchronization::onFindGroup, this, std::placeholders::_1)); } + bIsFinding = true; + // thread to check if GroupSynchronization::onFoundGroup is called or not. std::thread t(std::bind(&GroupSynchronization::checkFindGroup, this)); t.detach(); @@ -834,6 +840,7 @@ namespace OIC findCallback(NULL); } + bIsFinding = false; } catch (std::exception& e) { diff --git a/service/things-manager/sdk/src/GroupSynchronization.h b/service/things-manager/sdk/src/GroupSynchronization.h index da5f153..fdcea60 100644 --- a/service/things-manager/sdk/src/GroupSynchronization.h +++ b/service/things-manager/sdk/src/GroupSynchronization.h @@ -66,6 +66,7 @@ private: std::shared_ptr< OCResourceRequest > resourceRequest; // this is used for slow response static GroupSynchronization* groupSyncnstance; + static bool bIsFinding; GroupSynchronization() { -- 2.7.4