Handle Error during Ownership Transfer
authorJongmin Choi <jminl.choi@samsung.com>
Thu, 1 Dec 2016 07:23:05 +0000 (16:23 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Thu, 1 Dec 2016 10:24:55 +0000 (10:24 +0000)
If an error is returned during ownership transfer,
on-boarding tool needs to remove the server's information from PDM DB
and close secure connection with the server.

Patch #1: Initial patch
Patch #2: Change Log Level

Change-Id: I641529552de0e25438bd94da9b2ec45320428a61
Signed-off-by: Jongmin Choi <jminl.choi@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14999
Reviewed-by: Chul Lee <chuls.lee@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jongsung Lee <js126.lee@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/security/provisioning/src/ownershiptransfermanager.c

index 9e7f9ce32924bacbef71b8b01617e526153eb1d2..e07ebab3fb9d34313513cc844ced673952e7886c 100644 (file)
@@ -373,6 +373,16 @@ static void SetResult(OTMContext_t* otmCtx, const OCStackResult res)
             if(OC_STACK_OK != res && OC_STACK_CONTINUE != res && OC_STACK_DUPLICATE_REQUEST != res)
             {
                 otmCtx->ctxHasError = true;
+                if (OC_STACK_OK != PDMDeleteDevice(&otmCtx->ctxResultArray[i].deviceId))
+                {
+                    OIC_LOG(WARNING, TAG, "Internal error in PDMDeleteDevice");
+                }
+                CAEndpoint_t* endpoint = (CAEndpoint_t *)&otmCtx->selectedDeviceInfo->endpoint;
+                endpoint->port = otmCtx->selectedDeviceInfo->securePort;
+                if (CA_STATUS_OK != CAcloseSslConnection(endpoint))
+                {
+                    OIC_LOG(WARNING, TAG, "Failed to close Secure session");
+                }
             }
         }
     }