Update snapshot(2018-02-07) 27/169627/1 accepted/tizen/4.0/unified/20180209.064004 submit/tizen_4.0/20180208.081753
authorHongkuk, Son <hongkuk.son@samsung.com>
Thu, 8 Feb 2018 04:37:16 +0000 (13:37 +0900)
committerHongkuk, Son <hongkuk.son@samsung.com>
Thu, 8 Feb 2018 04:38:13 +0000 (13:38 +0900)
Signed-off-by: Hongkuk, Son <hongkuk.son@samsung.com>
Change-Id: I953fe651d854d3013b9b9f689ef6b7b0e166e16f

gbsbuild.sh
packaging/snapshot_history.txt
resource/csdk/connectivity/inc/catcpinterface.h
resource/csdk/connectivity/src/caqueueingthread.c
resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c
resource/csdk/stack/src/ocstack.c
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/gbsbuild.sh
service/resource-encapsulation/src/resourceCache/src/ResourceCacheManager.cpp

index 9532294..4872ca4 100755 (executable)
@@ -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
index 5ded465..73222c3 100755 (executable)
@@ -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
index 49b3f6a..d617365 100644 (file)
@@ -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
index 0eb1f3c..0afeed9 100644 (file)
@@ -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;
index cd33343..9eb0c76 100644 (file)
@@ -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)
index 661612e..f40c533 100644 (file)
@@ -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);
index 3051ad9..f5575b1 100644 (file)
@@ -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
index b00216e..bf8d3f0 100755 (executable)
@@ -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
index 8272570..8a3f020 100644 (file)
@@ -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();