if target_os in ['linux', 'tizen', 'android', 'ios', 'tizenrt']:
common_files = [
os.path.join(src_dir, 'catcpadapter.c'),
- os.path.join(src_dir, 'catcpserver.c') ]
+ os.path.join(src_dir, 'catcpserver.c'),
+ os.path.join(src_dir, 'catcpserver_mutex.c'),]
else :
common_files = [os.path.join(src_dir, 'catcpadapter.c')]
#include "caipnwmonitor.h"
#include <coap/pdu.h>
#include "caadapterutils.h"
+#include "catcpserver_mutex.h"
#include "octhread.h"
#include "oic_malloc.h"
#include "oic_string.h"
static uint32_t g_taskId = 0;
/**
- * Mutex to synchronize device object list.
- */
-static oc_mutex g_mutexObjectList = NULL;
-
-/**
- * Conditional mutex to synchronize.
- */
-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;
FDS[COUNT].fd = caglobals.tcp.TYPE.fd; \
FDS[COUNT].events = POLLIN;
-void CATCPDestroyMutex()
-{
- if (g_mutexObjectList)
- {
- oc_mutex_free(g_mutexObjectList);
- g_mutexObjectList = NULL;
- }
-}
-
-CAResult_t CATCPCreateMutex()
-{
- if (!g_mutexObjectList)
- {
- g_mutexObjectList = oc_mutex_new_recursive();
- if (!g_mutexObjectList)
- {
- OIC_LOG(ERROR, TAG, "Failed to create mutex!");
- return CA_STATUS_FAILED;
- }
- }
-
- return CA_STATUS_OK;
-}
-
-void CATCPDestroyCond()
-{
- if (g_condObjectList)
- {
- oc_cond_free(g_condObjectList);
- g_condObjectList = NULL;
- }
-}
-
-CAResult_t CATCPCreateCond()
-{
- if (!g_condObjectList)
- {
- g_condObjectList = oc_cond_new();
- if (!g_condObjectList)
- {
- 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;
- }
- }
- return CA_STATUS_OK;
-}
-
static void CAReceiveHandler(void *data)
{
(void)data;
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2019 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include "catcpserver_mutex.h"
+/**
+ * Logging tag for module name.
+ */
+//#define TAG "OIC_CA_TCP_SERVER"
+#define TAG TCP_SERVER_TAG
+
+/**
+ * Mutex to synchronize device object list.
+ */
+oc_mutex g_mutexObjectList = NULL;
+
+/**
+ * Conditional mutex to synchronize.
+ */
+oc_cond g_condObjectList= NULL;
+
+/**
+ * Mutex to synchronize send.
+ */
+oc_mutex g_mutexSend= NULL;
+
+/**
+ * Conditional mutex to synchronize send.
+ */
+oc_cond g_condSend= NULL;
+
+void CATCPDestroyMutex()
+{
+ if (g_mutexObjectList)
+ {
+ oc_mutex_free(g_mutexObjectList);
+ g_mutexObjectList = NULL;
+ }
+}
+
+CAResult_t CATCPCreateMutex()
+{
+ if (!g_mutexObjectList)
+ {
+ g_mutexObjectList = oc_mutex_new_recursive();
+ if (!g_mutexObjectList)
+ {
+ OIC_LOG(ERROR, TAG, "Failed to create mutex!");
+ return CA_STATUS_FAILED;
+ }
+ }
+
+ return CA_STATUS_OK;
+}
+
+void CATCPDestroyCond()
+{
+ if (g_condObjectList)
+ {
+ oc_cond_free(g_condObjectList);
+ g_condObjectList = NULL;
+ }
+}
+
+CAResult_t CATCPCreateCond()
+{
+ if (!g_condObjectList)
+ {
+ g_condObjectList = oc_cond_new();
+ if (!g_condObjectList)
+ {
+ 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;
+ }
+ }
+ return CA_STATUS_OK;
+}
--- /dev/null
+/* ****************************************************************
+*
+* Copyright 2019 Samsung Electronics All Rights Reserved.
+*
+*
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+******************************************************************/
+
+#ifndef CA_TCP_SERVER_MUTEX_H_
+#define CA_TCP_SERVER_MUTEX_H_
+
+#include "octhread.h"
+#include "oic_malloc.h"
+#include "oic_string.h"
+#include "catcpinterface.h"
+#include "caipnwmonitor.h"
+#include <coap/pdu.h>
+#include "caadapterutils.h"
+
+/**
+ * Mutex to synchronize device object list.
+ */
+extern oc_mutex g_mutexObjectList;
+
+/**
+ * Conditional mutex to synchronize.
+ */
+extern oc_cond g_condObjectList;
+
+/**
+ * Mutex to synchronize send.
+ */
+extern oc_mutex g_mutexSend;
+
+/**
+ * Conditional mutex to synchronize send.
+ */
+extern oc_cond g_condSend;
+
+void CATCPDestroyMutex();
+
+CAResult_t CATCPCreateMutex();
+
+void CATCPDestroyCond();
+
+CAResult_t CATCPCreateCond();
+
+void CATCPDestroySendMutex();
+
+CAResult_t CATCPCreateSendMutex();
+
+void CATCPDestroySendCond();
+
+CAResult_t CATCPCreateSendCond();
+
+#endif