{
ehResult = observer->resource->entityHandler(OC_REQUEST_FLAG, &ehRequest,
observer->resource->entityHandlerCallbackParam);
- if (ehResult == OC_EH_ERROR)
+
+ // Clear server request on error case
+ if (!OCResultToSuccess(EntityHandlerCodeToOCStackCode(ehResult)))
{
FindAndDeleteServerRequest(request);
}
OICStrcpy(ehResponse.resourceUri, sizeof(ehResponse.resourceUri),
resourceObserver->resUri);
result = OCDoResponse(&ehResponse);
+ if (result != OC_STACK_OK)
+ {
+ OIC_LOG(ERROR, TAG, "Failed to send presence notification!");
+ FindAndDeleteServerRequest(request);
+ }
}
OCPresencePayloadDestroy(presenceResBuf);
// Increment only if OCDoResponse is successful
numSentNotification++;
-
- OICFree(ehResponse.payload);
- FindAndDeleteServerRequest(request);
}
else
{
OIC_LOG_V(INFO, TAG, "Error notifying observer id %d.", *obsIdList);
+ FindAndDeleteServerRequest(request);
}
+
// Reset Observer TTL.
observer->TTL =
GetTicks(MAX_OBSERVER_TTL_SECONDS * MILLISECONDS_PER_SECOND);
+
+ OICFree(ehResponse.payload);
}
else
{
if (!options || !numOptions)
{
- OIC_LOG (DEBUG, TAG, "No options present");
+ OIC_LOG (INFO, TAG, "No options present");
return OC_STACK_OK;
}