This is VD specific requirement, not to close TCP
servers when interface down event is received.
New API "CAUtilSkipTCPCloseOnInterfaceDown" is
defined using which application can enable/disable
skip TCP server feature.
Signed-off-by: Harish Kumara M <h.marappa@samsung.com>
fix: save build error
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/388
(cherry picked from commit
725041caab8e0c1f14c6333cd066ea61a845893d)
Change-Id: Ifaf37379955d0d5615f08d43824148b6cbe075d3
Signed-off-by: Harish Kumara M <h.marappa@samsung.com>
Signed-off-by: Amit KS <amit.s12@samsung.com>
uint16_t port,
CATransportFlags_t flags);
uint16_t port,
CATransportFlags_t flags);
+/**
+ * Enable or disable skip closing TCP servers
+ * when network interface is down.
+ *
+ * @param[in] state true to skip closing TCP servers,
+ * otherwise false.
+ */
+void CAUtilSkipTCPCloseOnInterfaceDown(bool state);
+
CAResult_t CAUtilStartGattServer();
CAResult_t CAUtilStopGattServer();
CAResult_t CAUtilStartGattServer();
CAResult_t CAUtilStopGattServer();
CAResult_t CATCPDisconnectSession(const CAEndpoint_t *endpoint);
/**
CAResult_t CATCPDisconnectSession(const CAEndpoint_t *endpoint);
/**
+ * Enable or disable skip closing TCP servers
+ * when network interface is down.
+ *
+ * @param[in] state true to skip closing TCP servers,
+ * otherwise false.
+ */
+void CATCPSkipCloseOnInterfaceDown(bool state);
+
+/**
* Start listening server for receiving connect requests.
* Transport Specific Behavior:
* TCP Starts Listening Server on a particular interface and prefixed port
* Start listening server for receiving connect requests.
* Transport Specific Behavior:
* TCP Starts Listening Server on a particular interface and prefixed port
#define CA_TCP_SELECT_TIMEOUT 10
/**
#define CA_TCP_SELECT_TIMEOUT 10
/**
+ * Mutex to synchronize TCP adapter access.
+ */
+static oc_mutex g_mutexAdapter = NULL;
+
+/**
+ * State to control closing of TCP servers on interface down event.
+ */
+static bool g_skipCloseOnIFDown;
+
+/**
* Queue handle for Send Data.
*/
static CAQueueingThread_t *g_sendQueueHandle = NULL;
* Queue handle for Send Data.
*/
static CAQueueingThread_t *g_sendQueueHandle = NULL;
OIC_LOG_V(ERROR, TAG, "CAQueueingThreadClearData failed[%d]", res);
}
OIC_LOG_V(ERROR, TAG, "CAQueueingThreadClearData failed[%d]", res);
}
+ oc_mutex_lock(g_mutexAdapter);
+ if (!g_skipCloseOnIFDown)
+ {
+ CATCPStopServer();
+ }
+ else
+ {
+ OIC_LOG(INFO, TAG, "Skip closing servers!");
+ }
+ oc_mutex_unlock(g_mutexAdapter);
}
else if (CA_INTERFACE_UP == status)
{
}
else if (CA_INTERFACE_UP == status)
{
CAInitializeTCPGlobals();
CAInitializeTCPGlobals();
+ // Create Mutex for synchronize access at adapter level
+ if (!g_mutexAdapter)
+ {
+ g_mutexAdapter = oc_mutex_new();
+ if (!g_mutexAdapter)
+ {
+ OIC_LOG(ERROR, TAG, "Failed to create mutex!");
+ return CA_STATUS_FAILED;
+ }
+ }
+
+ g_skipCloseOnIFDown = false;
+
CAResult_t res = CATCPCreateMutex();
if (CA_STATUS_OK == res)
{
CAResult_t res = CATCPCreateMutex();
if (CA_STATUS_OK == res)
{
+void CATCPSkipCloseOnInterfaceDown(bool state)
+{
+ oc_mutex_lock(g_mutexAdapter);
+ g_skipCloseOnIFDown = state;
+ oc_mutex_unlock(g_mutexAdapter);
+}
+
CAResult_t CAStartTCPListeningServer()
{
#if !defined(SINGLE_THREAD) && !defined(DISABLE_TCP_SERVER)
CAResult_t CAStartTCPListeningServer()
{
#if !defined(SINGLE_THREAD) && !defined(DISABLE_TCP_SERVER)
CATCPDestroySendMutex();
CATCPDestroySendCond();
CATCPDestroySendMutex();
CATCPDestroySendCond();
+
+ g_skipCloseOnIFDown = false;
+
+ // Free adapter mutex
+ if (g_mutexAdapter)
+ {
+ oc_mutex_free(g_mutexAdapter);
+ g_mutexAdapter = NULL;
+ }
}
void CATCPSendDataThread(void *threadData)
}
void CATCPSendDataThread(void *threadData)
+void CAUtilSkipTCPCloseOnInterfaceDown(bool state)
+{
+#ifdef TCP_ADAPTER
+ CATCPSkipCloseOnInterfaceDown(state);
+#else
+ (void) state;
+ OIC_LOG(DEBUG, TAG, "Not supported!");
+#endif
+}
+
CAResult_t CAUtilStartGattServer()
{
OIC_LOG(DEBUG, TAG, "CAUtilStartGattServer");
CAResult_t CAUtilStartGattServer()
{
OIC_LOG(DEBUG, TAG, "CAUtilStartGattServer");