From: Oleksii Beketov
Date: Mon, 11 Mar 2019 16:49:38 +0000 (+0200)
Subject: Fix HandleDoxmPostRequest() to discard duplicate user confirm request
X-Git-Tag: submit/tizen/20190320.085337~4
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=064b3f910c8258d73bf1ee6e7c43f6623d649a79;p=platform%2Fupstream%2Fiotivity.git
Fix HandleDoxmPostRequest() to discard duplicate user confirm request
Sync with SES PR #537
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/55d327ade19bcc5bf0c61184056918a3525ee36f
(cherry picked from 55d327ade19bcc5bf0c61184056918a3525ee36f)
Change-Id: I6597949a83663afdc464aba05d6477cb265ac6d7
Signed-off-by: Oleksii Beketov
Signed-off-by: DoHyun Pyun
---
diff --git a/resource/csdk/security/src/doxmresource.c b/resource/csdk/security/src/doxmresource.c
index 116bb9a..6d35780 100644
--- a/resource/csdk/security/src/doxmresource.c
+++ b/resource/csdk/security/src/doxmresource.c
@@ -101,6 +101,7 @@ static oc_mutex g_mutexWait;
static oc_thread g_waitConfirmThreadId;
oc_cond g_condWait;
static InformOxmSelectedCallback_t g_InformOxmSelectedCallback = NULL;
+static bool g_isConfirmResult;
static OicSecOxm_t gOicSecDoxmJustWorks = OIC_JUST_WORKS;
static OicSecDoxm_t gDefaultDoxm =
@@ -1128,19 +1129,26 @@ void * WaitConfirm(OCEntityHandlerRequest * ehRequest)
oc_mutex_lock(g_mutexWait);
oc_cond_wait(g_condWait, g_mutexWait);
oc_cond_free(g_condWait);
+ g_condWait = NULL;
+
+ oc_mutex_unlock(g_mutexWait);
oc_mutex_free(g_mutexWait);
+ g_mutexWait = NULL;
+ g_isConfirmResult = true;
GetAsyncVerifyUserResult(&confirmResult, &confirmState);
if (confirmResult == true)
{
gConfirmState = CONFIRM_STATE_ACCEPTED;
HandleDoxmPostRequest(ehRequest);
+ g_isConfirmResult = false;
return NULL;
}
else
{
gConfirmState = CONFIRM_STATE_DENIED;
HandleDoxmPostRequest(ehRequest);
+ g_isConfirmResult = false;
return NULL;
}
@@ -1261,7 +1269,7 @@ static OCEntityHandlerResult HandleDoxmPostRequest(OCEntityHandlerRequest * ehRe
* In case of other transport adapter, duplicate message check is not required.
*/
if (OC_ADAPTER_IP == ehRequest->devAddr.adapter &&
- previousMsgId == ehRequest->messageID)
+ previousMsgId == ehRequest->messageID && g_isConfirmResult == false)
{
isDuplicatedMsg = true;
}
@@ -1640,6 +1648,9 @@ static OCEntityHandlerResult HandleDoxmPostRequest(OCEntityHandlerRequest * ehRe
{
oc_thread_detach(g_waitConfirmThreadId);
}
+
+ previousMsgId = ehRequest->messageID;
+
return OC_EH_SLOW;
}
}