[PLUGIN-INTERFACE] Delete resources when a request has failed.
authorJoseph Morrow <joseph.l.morrow@intel.com>
Tue, 3 Nov 2015 18:39:27 +0000 (10:39 -0800)
committerJon A. Cruz <jonc@osg.samsung.com>
Mon, 16 Nov 2015 23:10:49 +0000 (23:10 +0000)
This will allow for the Plugin-Interface module to delete resources which
are no longer properly mapped.

Change-Id: I7a3f0022b49aa6ebdae016b7f416df2ced0952d7
Signed-off-by: Joseph Morrow <joseph.l.morrow@intel.com>
Signed-off-by: Thuyen Tran <thuyen.c.tran@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3791
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
plugins/src/plugininterface.c

index 29ce028..d617a87 100644 (file)
@@ -95,6 +95,15 @@ OCEntityHandlerResult PluginInterfaceEntityHandler(OCEntityHandlerFlag flag,
     else
     {
         OC_LOG_V(ERROR, TAG, "Error handling request %u", ehResult);
+        PIResource * piResource = NULL;
+        result = GetResourceFromHandle(plugin, &piResource, response->resourceHandle);
+        OC_LOG_V(ERROR, TAG, "Deleting resource \"%s\" because of failed request.", piResource->uri);
+        result = DeleteResource(plugin, piResource);
+        if(result != OC_STACK_OK)
+        {
+            OC_LOG_V(ERROR, TAG, "Failed to delete resource after failed request.");
+            ehResult = OC_EH_ERROR;
+        }
     }
 
     OCPayloadDestroy(response->payload);