+http://suprem.sec.samsung.net/jira/browse/CONPRO-1172
+
+[CONPRO-1172] allocates too much memory
+
+ - manually patched from below 2 pull requests because of VD PVR schedule
+
+ - https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/206
+ - https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/209
+----------------------------------------------------------------------------------------------------------------------------------
http://suprem.sec.samsung.net/jira/browse/CONPRO-1169
commit_info_2017-12-20.txt
CAResult_t CAQueueingThreadDestroy(CAQueueingThread_t *thread);
+uint32_t CAQueueingThreadGetQueueSize(CAQueueingThread_t *thread);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
#define CA_MAX_RT_ARRAY_SIZE 3
#endif // SINGLE_THREAD
+#define RECEIVE_QUEUE_MAX_SIZE 100
+
#define TAG "OIC_CA_MSG_HANDLE"
static CARetransmission_t g_retransmissionContext;
return ret;
}
+// NOTE: This is test method for CONPRO-1172
+static SendDirectErrorResponsetoPeer(CAData_t* cadata)
+{
+ CARequestInfo_t *reqInfo = cadata->requestInfo;
+
+ CAResponseInfo_t respInfo = { .result = CA_INTERNAL_SERVER_ERROR };
+ respInfo.info.messageId = reqInfo->info.messageId;
+ respInfo.info.numOptions = reqInfo->info.numOptions;
+
+ if (respInfo.info.numOptions)
+ {
+ respInfo.info.options =
+ (CAHeaderOption_t *)OICCalloc(respInfo.info.numOptions, sizeof(CAHeaderOption_t));
+ memcpy (respInfo.info.options, reqInfo->info.options,
+ sizeof(CAHeaderOption_t) * respInfo.info.numOptions);
+
+ }
+
+ respInfo.info.payload = NULL;
+ respInfo.info.token = reqInfo->info.token;
+ respInfo.info.tokenLength = reqInfo->info.tokenLength;
+ respInfo.info.type = reqInfo->info.type;
+ respInfo.info.resourceUri = OICStrdup (reqInfo->info.resourceUri);
+ respInfo.info.acceptFormat = CA_FORMAT_UNDEFINED;
+ respInfo.info.dataType = CA_RESPONSE_DATA;
+
+ CAResult_t caResult = CASendResponse(cadata->remoteEndpoint, &respInfo);
+ // resourceUri in the info field is cloned in the CA layer and
+ // thus ownership is still here.
+ OICFree (respInfo.info.resourceUri);
+ OICFree (respInfo.info.options);
+ if(CA_STATUS_OK != caResult)
+ {
+ OIC_LOG_V(ERROR, TAG, "CASendResponse error - %d", caResult);
+ }
+}
+
static CAResult_t CAReceivedPacketCallback(const CASecureEndpoint_t *sep,
const void *data, uint32_t dataLen)
{
else
#endif
{
- CAQueueingThreadAddData(&g_receiveThread, cadata, sizeof(CAData_t));
+ // NOTE: This is test logic for CONPRO-1172
+ size_t queueSize = CAQueueingThreadGetQueueSize(&g_receiveThread);
+ if (queueSize <= RECEIVE_QUEUE_MAX_SIZE)
+ {
+ CAQueueingThreadAddData(&g_receiveThread, cadata, sizeof(CAData_t));
+ }
+ else
+ {
+ OIC_LOG_V(INFO, TAG, "Receive queue size(%"PRIuPTR") is > its threshold limit(%d)", queueSize, RECEIVE_QUEUE_MAX_SIZE);
+ SendDirectErrorResponsetoPeer(cadata);
+ CADestroyData(cadata, sizeof(CAData_t));
+ }
}
#endif // SINGLE_THREAD
return CA_STATUS_OK;
}
+
+uint32_t CAQueueingThreadGetQueueSize(CAQueueingThread_t *thread)
+{
+ uint32_t size = 0;
+
+ if (thread)
+ {
+ oc_mutex_lock(thread->threadMutex);
+ size = u_queue_get_size(thread->dataQueue);
+ oc_mutex_unlock(thread->threadMutex);
+ }
+
+ return size;
+}
#if defined(ARDUINO) || defined(__TIZENRT__)
#define MAX_HEADER_OPTIONS (2)
#else
-#define MAX_HEADER_OPTIONS (50)
+//#define MAX_HEADER_OPTIONS (50)
+// For CONPRO-1172
+#define MAX_HEADER_OPTIONS (5)
#endif
/**
if (!options || !numOptions)
{
- OIC_LOG (INFO, TAG, "No options present");
+ OIC_LOG (DEBUG, TAG, "No options present");
return OC_STACK_OK;
}
break;
}
- OIC_LOG_V(INFO, TAG, "Finished parse payload, result is %d", result);
-
exit:
return result;
}
{
if (!query)
{
- OIC_LOG_V(ERROR, TAG, "Query is empty!");
return OC_STACK_INVALID_QUERY;
}
char *key = NULL;
}
else
{
- OIC_LOG_V(ERROR, TAG, "Unsupported query key: %s", key);
goto exit;
}
++numKeyValuePairsParsed;
* proper destination and remove "RM" coap header option before passing request / response to
* RI as this option will make no sense to either RI or application.
*/
- RMUpdateInfo((CAHeaderOption_t **) &(responseInfo->info.options),
+ if (responseInfo->info.options)
+ {
+ RMUpdateInfo((CAHeaderOption_t **) &(responseInfo->info.options),
(uint8_t *) &(responseInfo->info.numOptions),
(CAEndpoint_t *) endPoint);
+ }
#endif
OCHandleResponse(endPoint, responseInfo);
{
OIC_LOG_V(ERROR, TAG, "HandleStackRequests failed. error: %d", requestResult);
+ // Delete observer node if it is OBSERVE failure from app
+ if (serverRequest.observationOption == OC_OBSERVE_REGISTER)
+ {
+ DeleteObserverUsingToken(requestInfo->info.token, requestInfo->info.tokenLength);
+ }
+
CAResponseResult_t stackResponse =
OCToCAStackResult(requestResult, serverRequest.method);
* Put source in sender endpoint so that the next packet from application can be routed to
* proper destination and remove RM header option.
*/
- RMUpdateInfo((CAHeaderOption_t **) &(requestInfo->info.options),
+ if (requestInfo->info.options)
+ {
+ RMUpdateInfo((CAHeaderOption_t **) &(requestInfo->info.options),
(uint8_t *) &(requestInfo->info.numOptions),
(CAEndpoint_t *) endPoint);
+ }
#ifdef ROUTING_GATEWAY
if (isEmptyMsg)