diff options
author | Hongkuk, Son <hongkuk.son@samsung.com> | 2017-11-15 11:34:20 +0900 |
---|---|---|
committer | Hongkuk, Son <hongkuk.son@samsung.com> | 2017-11-15 11:34:50 +0900 |
commit | 61246acb204a2952b31cf6441766e7a6a18ff4e6 (patch) | |
tree | 9edae55224e5b7997b3f2b8ef4f4d4c8f46bbd29 | |
parent | 488e9742961aafb57d5653e56f88846575bb1f3d (diff) | |
download | iotivity-accepted/tizen/unified/20171115.174050.tar.gz iotivity-accepted/tizen/unified/20171115.174050.tar.bz2 iotivity-accepted/tizen/unified/20171115.174050.zip |
Update snapshot(2017-11-14)submit/tizen/20171115.060233accepted/tizen/unified/20171115.174050
Signed-off-by: Hongkuk, Son <hongkuk.son@samsung.com>
Change-Id: Ief7e3ae9c8c4e11ab1f7f82d05b3879fc5afc0ef
-rwxr-xr-x | packaging/snapshot_history.txt | 6 | ||||
-rwxr-xr-x | resource/csdk/connectivity/src/cainterfacecontroller.c | 49 | ||||
-rw-r--r-- | resource/csdk/connectivity/src/tcp_adapter/catcpserver.c | 2 |
3 files changed, 56 insertions, 1 deletions
diff --git a/packaging/snapshot_history.txt b/packaging/snapshot_history.txt index 7de6bb05c..9b727a771 100755 --- a/packaging/snapshot_history.txt +++ b/packaging/snapshot_history.txt @@ -1,3 +1,9 @@ +http://suprem.sec.samsung.net/jira/browse/CONPRO-1131 + +commit_info_2017-11-14.txt + +commit_id: f8b740a6b97c456423747719284085dc21c8066f +---------------------------------------------------------------------------------------------------------------------------------- http://suprem.sec.samsung.net/jira/browse/CONPRO-1124 commit_info_2017-11-08.txt diff --git a/resource/csdk/connectivity/src/cainterfacecontroller.c b/resource/csdk/connectivity/src/cainterfacecontroller.c index 525f79f60..c89228914 100755 --- a/resource/csdk/connectivity/src/cainterfacecontroller.c +++ b/resource/csdk/connectivity/src/cainterfacecontroller.c @@ -37,6 +37,7 @@ #include "cainterface.h" #include "caipinterface.h" #include <coap/utlist.h> +#include "octhread.h" #ifdef RA_ADAPTER #include "caraadapter.h" @@ -66,6 +67,11 @@ static CAErrorHandleCallback g_errorHandleCallback = NULL; static struct CANetworkCallback_t * g_networkChangeCallbackList = NULL; /** + * Mutex to synchronize network change list. + */ +static oc_mutex g_mutexNetCallbackList = NULL; + +/** * network callback structure is handling * for adapter state changed and connection state changed event. */ @@ -146,12 +152,14 @@ static CAResult_t AddNetworkStateChangedCallback(CAAdapterStateChangedCB adapter return CA_STATUS_INVALID_PARAM; } + oc_mutex_lock(g_mutexNetCallbackList); CANetworkCallback_t* callback = NULL; LL_FOREACH(g_networkChangeCallbackList, callback) { if (callback && adapterCB == callback->adapter && connCB == callback->conn) { OIC_LOG(DEBUG, TAG, "this callback is already added"); + oc_mutex_unlock(g_mutexNetCallbackList); return CA_STATUS_OK; } } @@ -160,12 +168,14 @@ static CAResult_t AddNetworkStateChangedCallback(CAAdapterStateChangedCB adapter if (NULL == callback) { OIC_LOG(ERROR, TAG, "Memory allocation failed during registration"); + oc_mutex_unlock(g_mutexNetCallbackList); return CA_MEMORY_ALLOC_FAILED; } callback->adapter = adapterCB; callback->conn = connCB; LL_APPEND(g_networkChangeCallbackList, callback); + oc_mutex_unlock(g_mutexNetCallbackList); OIC_LOG_V(INFO, TAG, "Added NetworkStateChanged Callback [%p]", callback); return CA_STATUS_OK; @@ -185,6 +195,7 @@ static CAResult_t RemoveNetworkStateChangedCallback(CAAdapterStateChangedCB adap { OIC_LOG(DEBUG, TAG, "Remove NetworkStateChanged Callback"); + oc_mutex_lock(g_mutexNetCallbackList); CANetworkCallback_t* callback = NULL; LL_FOREACH(g_networkChangeCallbackList, callback) { @@ -192,10 +203,13 @@ static CAResult_t RemoveNetworkStateChangedCallback(CAAdapterStateChangedCB adap { OIC_LOG(DEBUG, TAG, "remove specific callback"); LL_DELETE(g_networkChangeCallbackList, callback); + oc_mutex_unlock(g_mutexNetCallbackList); OICFree(callback); return CA_STATUS_OK; } } + oc_mutex_unlock(g_mutexNetCallbackList); + return CA_STATUS_OK; } @@ -222,6 +236,8 @@ static CAResult_t CAReceivedPacketCallback(const CASecureEndpoint_t *sep, static void CAAdapterChangedCallback(CATransportAdapter_t adapter, CANetworkStatus_t status) { + + oc_mutex_lock(g_mutexNetCallbackList); // Call the callback. CANetworkCallback_t* callback = NULL; LL_FOREACH(g_networkChangeCallbackList, callback) @@ -240,12 +256,14 @@ static void CAAdapterChangedCallback(CATransportAdapter_t adapter, CANetworkStat OIC_LOG_V(INFO, TAG, "OUT application adapter changed callback [%p]", callback); } } + oc_mutex_unlock(g_mutexNetCallbackList); OIC_LOG_V(DEBUG, TAG, "[%d] adapter status is changed to [%d]", adapter, status); } #if defined(TCP_ADAPTER) || defined(EDR_ADAPTER) || defined(LE_ADAPTER) static void CAConnectionChangedCallback(const CAEndpoint_t *info, bool isConnected) { + oc_mutex_lock(g_mutexNetCallbackList); // Call the callback. CANetworkCallback_t* callback = NULL; LL_FOREACH(g_networkChangeCallbackList, callback) @@ -255,6 +273,7 @@ static void CAConnectionChangedCallback(const CAEndpoint_t *info, bool isConnect callback->conn(info, isConnected); } } + oc_mutex_unlock(g_mutexNetCallbackList); OIC_LOG_V(DEBUG, TAG, "[%s] connection status is changed to [%d]", info->addr, isConnected); } #endif @@ -272,10 +291,38 @@ static void CAAdapterErrorHandleCallback(const CAEndpoint_t *endpoint, } } +static void CADestroyMutex() +{ + if (g_mutexNetCallbackList) + { + oc_mutex_free(g_mutexNetCallbackList); + g_mutexNetCallbackList = NULL; + } +} + +static CAResult_t CACreateMutex() +{ + if (!g_mutexNetCallbackList) + { + g_mutexNetCallbackList = oc_mutex_new(); + if (!g_mutexNetCallbackList) + { + return CA_STATUS_FAILED; + } + } + + return CA_STATUS_OK; +} + void CAInitializeAdapters(ca_thread_pool_t handle, CATransportAdapter_t transportType) { OIC_LOG_V(DEBUG, TAG, "initialize adapters %d", transportType); + if (CA_STATUS_OK != CACreateMutex()) + { + OIC_LOG(ERROR, TAG, "Failed to create mutex!"); + } + // Initialize ssl adapter. #if defined(__WITH_DTLS__) || defined(__WITH_TLS__) if (CA_STATUS_OK != CAinitSslAdapter()) @@ -780,6 +827,8 @@ CAResult_t CAStartDiscoveryServerAdapters() void CATerminateAdapters() { + CADestroyMutex(); + for (uint32_t index = 0; index < g_numberOfAdapters; index++) { if (g_adapterHandler[index].terminate != NULL) diff --git a/resource/csdk/connectivity/src/tcp_adapter/catcpserver.c b/resource/csdk/connectivity/src/tcp_adapter/catcpserver.c index f698c888c..2d7df005c 100644 --- a/resource/csdk/connectivity/src/tcp_adapter/catcpserver.c +++ b/resource/csdk/connectivity/src/tcp_adapter/catcpserver.c @@ -1126,7 +1126,7 @@ static ssize_t sendData(const CAEndpoint_t *endpoint, const void *data, return len; } sendCounter++; - OIC_LOG_V(WARNING, TAG, "send blocked. trying %n attempt from 100", sendCounter); + OIC_LOG_V(WARNING, TAG, "send blocked. trying %zu attempt from 100", sendCounter); if(sendCounter >= 100) { return len; |