{
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 ((memcmp(out->token, token, tokenLength) == 0))
{
OIC_LOG(INFO, TAG, "Found in observer list");
+ ResourceObserver *observer = CloneObserverNode(out);
oc_mutex_unlock(g_serverObsListMutex);
- return CloneObserverNode(out);
+ return observer;
}
CheckTimedOutObserver(out);
}