From 1e743d337b66bda0e44a5ca500d4d7178bb599b5 Mon Sep 17 00:00:00 2001 From: "Hongkuk, Son" Date: Thu, 8 Feb 2018 13:37:16 +0900 Subject: [PATCH] Update snapshot(2018-02-07) Signed-off-by: Hongkuk, Son Signed-off-by: DoHyun Pyun Change-Id: Id7dbc4ca15ab77968a5b2d8103a1bc045c76af04 --- gbsbuild.sh | 4 +- packaging/snapshot_history.txt | 6 ++ resource/csdk/connectivity/inc/catcpinterface.h | 25 ++++++ resource/csdk/connectivity/src/caqueueingthread.c | 1 + .../connectivity/src/tcp_adapter/catcpadapter.c | 18 +++++ .../connectivity/src/tcp_adapter/catcpserver.c | 91 ++++++++++++++++++++-- resource/csdk/stack/src/ocstack.c | 1 + .../EnrolleeSample/build/tizen/gbsbuild.sh | 2 +- .../src/resourceCache/src/ResourceCacheManager.cpp | 2 - 9 files changed, 139 insertions(+), 11 deletions(-) diff --git a/gbsbuild.sh b/gbsbuild.sh index 9532294..4872ca4 100755 --- a/gbsbuild.sh +++ b/gbsbuild.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -spec=`ls tools/tizen/*.spec` +spec=`ls tools/tizen/iotivity.spec` version=`rpm --query --queryformat '%{version}\n' --specfile $spec` name=`echo $name|cut -d" " -f 1` @@ -39,7 +39,7 @@ cp -R ./extlibs/libcoap $sourcedir/tmp/extlibs cp -R ./resource $sourcedir/tmp cp -R ./service $sourcedir/tmp cp ./extra_options.scons $sourcedir/tmp -cp ./tools/tizen/*.spec ./tmp/packaging +cp ./tools/tizen/iotivity.spec ./tmp/packaging cp ./tools/tizen/*.manifest ./tmp/packaging cp ./SConstruct ./tmp cp ./LICENSE.md ./tmp diff --git a/packaging/snapshot_history.txt b/packaging/snapshot_history.txt index 035b472..ab662ae 100755 --- a/packaging/snapshot_history.txt +++ b/packaging/snapshot_history.txt @@ -1,3 +1,9 @@ +http://suprem.sec.samsung.net/jira/browse/CONPRO-1224 + +commit_info_2018-02-07.txt + +commit_id: 4fe181c2004480bcf285b4842892c63004f34bfa +---------------------------------------------------------------------------------------------------------------------------------- http://suprem.sec.samsung.net/jira/browse/CONPRO-1216 commit_info_2018-01-31.txt diff --git a/resource/csdk/connectivity/inc/catcpinterface.h b/resource/csdk/connectivity/inc/catcpinterface.h index 49b3f6a..d617365 100644 --- a/resource/csdk/connectivity/inc/catcpinterface.h +++ b/resource/csdk/connectivity/inc/catcpinterface.h @@ -283,6 +283,19 @@ CAResult_t CATCPCreateMutex(); void CATCPDestroyMutex(); /** + * Create a mutex object for send data. + * + * @return ::CA_STATUS_OK or Appropriate error code. + */ +CAResult_t CATCPCreateSendMutex(); + +/** + * Close a mutex object for send data. + */ +void CATCPDestroySendMutex(); + + +/** * Initialize a condition variable. * * @return ::CA_STATUS_OK or Appropriate error code. @@ -294,6 +307,18 @@ CAResult_t CATCPCreateCond(); */ void CATCPDestroyCond(); +/** + * Initialize a condition variable for send data. + * + * @return ::CA_STATUS_OK or Appropriate error code. + */ +CAResult_t CATCPCreateSendCond(); + +/** + * Destroy condition variable state for send data. + */ +void CATCPDestroySendCond(); + #ifdef __cplusplus } #endif diff --git a/resource/csdk/connectivity/src/caqueueingthread.c b/resource/csdk/connectivity/src/caqueueingthread.c index 0eb1f3c..0afeed9 100644 --- a/resource/csdk/connectivity/src/caqueueingthread.c +++ b/resource/csdk/connectivity/src/caqueueingthread.c @@ -366,6 +366,7 @@ CAResult_t CAQueueingThreadDestroy(CAQueueingThread_t *thread) oc_mutex_free(thread->threadMutex); thread->threadMutex = NULL; oc_cond_free(thread->threadCond); + thread->threadCond = NULL; u_queue_delete(thread->dataQueue); thread->dataQueue = NULL; diff --git a/resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c b/resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c index cd33343..9eb0c76 100644 --- a/resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c +++ b/resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c @@ -374,6 +374,21 @@ CAResult_t CAInitializeTCP(CARegisterConnectivityCallback registerCallback, return res; } + res = CATCPCreateSendMutex(); + if (CA_STATUS_OK == res) + { + res = CATCPCreateSendCond(); + } + if (CA_STATUS_OK != res) + { + OIC_LOG(ERROR, TAG, "failed to create send data mutex/cond"); + CATCPDestroyMutex(); + CATCPDestroyCond(); + CATCPDestroySendMutex(); + CATCPDestroySendCond(); + return res; + } + #ifndef SINGLE_THREAD caglobals.tcp.threadpool = handle; #endif @@ -625,6 +640,9 @@ void CATerminateTCP() CATCPDestroyMutex(); CATCPDestroyCond(); + + CATCPDestroySendMutex(); + CATCPDestroySendCond(); } void CATCPSendDataThread(void *threadData) diff --git a/resource/csdk/connectivity/src/tcp_adapter/catcpserver.c b/resource/csdk/connectivity/src/tcp_adapter/catcpserver.c index 661612e..f40c533 100644 --- a/resource/csdk/connectivity/src/tcp_adapter/catcpserver.c +++ b/resource/csdk/connectivity/src/tcp_adapter/catcpserver.c @@ -77,6 +77,8 @@ #define COAP_TCP_MAX_BUFFER_CHUNK_SIZE 65530 //64kb - 6 (coap+tcp max header size) +#define MILLISECONDS_PER_SECOND (1000) + /** * Thread pool. */ @@ -93,6 +95,16 @@ static oc_mutex g_mutexObjectList = NULL; static oc_cond g_condObjectList = NULL; /** + * Mutex to synchronize send. + */ +static oc_mutex g_mutexSend = NULL; + +/** + * Conditional mutex to synchronize send. + */ +static oc_cond g_condSend = NULL; + +/** * Maintains the callback to be notified when data received from remote device. */ static CATCPPacketReceivedCallback g_packetReceivedCallback = NULL; @@ -150,7 +162,7 @@ CAResult_t CATCPCreateMutex() g_mutexObjectList = oc_mutex_new(); if (!g_mutexObjectList) { - OIC_LOG(ERROR, TAG, "Failed to created mutex!"); + OIC_LOG(ERROR, TAG, "Failed to create mutex!"); return CA_STATUS_FAILED; } } @@ -174,7 +186,54 @@ CAResult_t CATCPCreateCond() g_condObjectList = oc_cond_new(); if (!g_condObjectList) { - OIC_LOG(ERROR, TAG, "Failed to created cond!"); + OIC_LOG(ERROR, TAG, "Failed to create cond!"); + return CA_STATUS_FAILED; + } + } + return CA_STATUS_OK; +} + +void CATCPDestroySendMutex() +{ + if (g_mutexSend) + { + oc_mutex_free(g_mutexSend); + g_mutexSend = NULL; + } +} + +CAResult_t CATCPCreateSendMutex() +{ + if (!g_mutexSend) + { + g_mutexSend = oc_mutex_new(); + if (!g_mutexSend) + { + OIC_LOG(ERROR, TAG, "Failed to create send mutex!"); + return CA_STATUS_FAILED; + } + } + + return CA_STATUS_OK; +} + +void CATCPDestroySendCond() +{ + if (g_condSend) + { + oc_cond_free(g_condSend); + g_condSend = NULL; + } +} + +CAResult_t CATCPCreateSendCond() +{ + if (!g_condSend) + { + g_condSend = oc_cond_new(); + if (!g_condSend) + { + OIC_LOG(ERROR, TAG, "Failed to create send cond!"); return CA_STATUS_FAILED; } } @@ -1075,6 +1134,10 @@ void CATCPStopServer() // set terminate flag. caglobals.tcp.terminate = true; + oc_mutex_lock(g_mutexSend); + oc_cond_signal(g_condSend); + oc_mutex_unlock(g_mutexSend); + #ifdef __TIZENRT__ if (caglobals.tcp.started) { @@ -1189,7 +1252,7 @@ static ssize_t sendData(const CAEndpoint_t *endpoint, const void *data, // #2. send data to remote device. ssize_t remainLen = dlen; - size_t sendCounter = 0; + unsigned int sendRetryTime = 1; do { #ifdef MSG_NOSIGNAL @@ -1206,14 +1269,30 @@ static ssize_t sendData(const CAEndpoint_t *endpoint, const void *data, len, false, strerror(errno)); return len; } - sendCounter++; - OIC_LOG_V(WARNING, TAG, "send blocked. trying %zu attempt from 25", sendCounter); - if(sendCounter >= 25) + + // re-trying send after 10, 20, 40, 80, 160 and 320 milliseconds + if (sendRetryTime > 32) { return len; } + + unsigned int waitTime = sendRetryTime * 10 * MILLISECONDS_PER_SECOND; + OIC_LOG_V(WARNING, TAG, "send blocked. trying send after %u microseconds", waitTime); + + oc_mutex_lock(g_mutexSend); + oc_cond_wait_for(g_condSend, g_mutexSend, waitTime); + oc_mutex_unlock(g_mutexSend); + + if (caglobals.tcp.terminate) + { + return len; + } + + sendRetryTime = (sendRetryTime << 1); + continue; } + sendRetryTime = 1; data += len; remainLen -= len; } while (remainLen > 0); diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index 3051ad9..f5575b1 100644 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -3126,6 +3126,7 @@ OCStackResult OCDoRequest(OCDoHandle *handle, goto exit; } + token = NULL; // Client CB list entry now owns it devAddr = NULL; // Client CB list entry now owns it resourceUri = NULL; // Client CB list entry now owns it resourceType = NULL; // Client CB list entry now owns it diff --git a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/gbsbuild.sh b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/gbsbuild.sh index b00216e..bf8d3f0 100755 --- a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/gbsbuild.sh +++ b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/gbsbuild.sh @@ -41,7 +41,7 @@ cp -R ./extlibs/libcoap $sourcedir/tmp/extlibs cp -R ./resource $sourcedir/tmp cp -R ./service $sourcedir/tmp cp ./extra_options.scons $sourcedir/tmp -cp ./tools/tizen/*.spec ./tmp/packaging +cp ./tools/tizen/iotivity.spec ./tmp/packaging cp ./tools/tizen/*.manifest ./tmp/packaging cp ./SConstruct ./tmp cp ./LICENSE.md ./tmp diff --git a/service/resource-encapsulation/src/resourceCache/src/ResourceCacheManager.cpp b/service/resource-encapsulation/src/resourceCache/src/ResourceCacheManager.cpp index 8272570..8a3f020 100644 --- a/service/resource-encapsulation/src/resourceCache/src/ResourceCacheManager.cpp +++ b/service/resource-encapsulation/src/resourceCache/src/ResourceCacheManager.cpp @@ -133,7 +133,6 @@ namespace OIC if ((dataCacheIns == cacheIDmap.end() && observeIns == observeCacheIDmap.end()) || id == 0) { - lock.~lock_guard(); throw RCSInvalidParameterException {"[cancelResourceCache] CacheID is invaild"}; } @@ -147,7 +146,6 @@ namespace OIC { (observeIns->second).reset(); observeCacheIDmap.erase(id); - lock.~lock_guard(); throw; } (observeIns->second).reset(); -- 2.7.4