Add mutex lock/unlock 74/203574/7
authorhyunuktak <hyunuk.tak@samsung.com>
Tue, 16 Apr 2019 04:29:24 +0000 (13:29 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Wed, 8 May 2019 07:36:14 +0000 (16:36 +0900)
It's one of the processess for multi-thread safety.

Change-Id: Id5480690d453bd962fb8fd74da14fbfbfdeeff1f
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
include/net_connection_private.h
packaging/capi-network-connection.spec
src/connection.c
src/connection_profile.c
src/libnetwork.c

index a5b59be..1e73281 100755 (executable)
@@ -56,11 +56,23 @@ typedef enum {
        CONNECTION_SUPPORTED_FEATURE_MAX,
 } connection_supported_feature_e;
 
+#define CONN_LOCK \
+       do { \
+               _connection_lock(); \
+       } while(0)
+
+#define CONN_UNLOCK \
+       do { \
+               _connection_unlock(); \
+       } while(0)
+
 #define CHECK_FEATURE_SUPPORTED(...) \
        do { \
                int rv = _connection_check_feature_supported(__VA_ARGS__, NULL); \
-               if (rv != CONNECTION_ERROR_NONE) \
+               if (rv != CONNECTION_ERROR_NONE) { \
+                       CONN_UNLOCK; \
                        return rv; \
+               } \
        } while (0)
 
 #define DEPRECATED_LOG(origin, substitution) \
@@ -193,6 +205,9 @@ int _connection_libnet_stop_tcpdump(connection_handle_s *conn_handle);
 int _connection_libnet_get_tcpdump_state(connection_handle_s *conn_handle,
                        gboolean *tcpdump_state);
 
+void _connection_lock(void);
+void _connection_unlock(void);
+
 bool _connection_check_handle_validity(connection_h connection);
 #ifdef __cplusplus
 }
index dc7488c..636e074 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          capi-network-connection
 Summary:       Network Connection library in TIZEN C API
-Version:       1.0.114
+Version:       1.0.115
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index bde3359..e53dcb3 100755 (executable)
@@ -79,117 +79,112 @@ bool _connection_check_handle_validity(connection_h connection)
        return __connection_check_handle_validity(connection);
 }
 
-static int __connection_set_type_changed_callback(connection_handle_s *conn_handle,
+static void __connection_set_type_changed_callback(connection_handle_s *conn_handle,
                        void *callback, void *user_data)
 {
        conn_handle->type_changed_user_data = user_data;
        conn_handle->type_changed_callback = callback;
-
-       return CONNECTION_ERROR_NONE;
 }
 
-static int __connection_set_ip_changed_callback(connection_handle_s *conn_handle,
+static void __connection_set_ip_changed_callback(connection_handle_s *conn_handle,
                        void *callback, void *user_data)
 {
        conn_handle->ip_changed_user_data = user_data;
        conn_handle->ip_changed_callback = callback;
-
-       return CONNECTION_ERROR_NONE;
 }
 
-static int __connection_set_proxy_changed_callback(connection_handle_s *conn_handle,
+static void __connection_set_proxy_changed_callback(connection_handle_s *conn_handle,
                        void *callback, void *user_data)
 {
        conn_handle->proxy_changed_user_data = user_data;
        conn_handle->proxy_changed_callback = callback;
-
-       return CONNECTION_ERROR_NONE;
 }
 
-static int __connection_set_ethernet_cable_state_changed_cb(connection_handle_s *conn_handle,
+static void __connection_set_ethernet_cable_state_changed_cb(connection_handle_s *conn_handle,
                        void *callback, void *user_data)
 {
        conn_handle->ethernet_cable_state_changed_callback = callback;
        conn_handle->ethernet_cable_state_changed_user_data = user_data;
-
-       return CONNECTION_ERROR_NONE;
 }
 
-static int __connection_set_default_cellular_service_profile_callback(connection_handle_s *conn_handle,
+static void __connection_set_default_cellular_service_profile_callback(connection_handle_s *conn_handle,
                        void *callback, void *user_data)
 {
        conn_handle->set_default_callback = callback;
        conn_handle->set_default_user_data = user_data;
-
-       return CONNECTION_ERROR_NONE;
 }
 
-static int __connection_open_profile_set_callback(connection_handle_s *conn_handle,
+static void __connection_open_profile_set_callback(connection_handle_s *conn_handle,
                        void *callback, void *user_data)
 {
        conn_handle->opened_callback = callback;
        conn_handle->opened_user_data = user_data;
-
-       return CONNECTION_ERROR_NONE;
 }
 
-static int __connection_close_profile_set_callback(connection_handle_s *conn_handle,
+static void __connection_close_profile_set_callback(connection_handle_s *conn_handle,
                        void *callback, void *user_data)
 {
        conn_handle->closed_callback = callback;
        conn_handle->closed_user_data = user_data;
-
-       return CONNECTION_ERROR_NONE;
 }
 
-static int __connection_reset_profile_set_callback(connection_handle_s *conn_handle,
+static void __connection_reset_profile_set_callback(connection_handle_s *conn_handle,
                        void *callback, void *user_data)
 {
        conn_handle->reset_callback = callback;
        conn_handle->reset_user_data = user_data;
-
-       return CONNECTION_ERROR_NONE;
 }
 //LCOV_EXCL_STOP
 
 /* Connection Manager ********************************************************/
 EXPORT_API int connection_create(connection_h *connection)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        int rv;
 
        if (connection == NULL || __connection_check_handle_validity(*connection)) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        *connection = g_try_malloc0(sizeof(connection_handle_s));
-       if (*connection != NULL)
+       if (*connection != NULL) {
                CONNECTION_LOG(CONNECTION_INFO, "New handle created[%p]", *connection);
-       else
+       } else {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+       }
 
        rv = _connection_libnet_init(*connection);
        if (rv == NET_ERR_ACCESS_DENIED) {
                CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to create connection[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
        conn_handle_list = g_slist_prepend(conn_handle_list, *connection);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_destroy(connection_h connection)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -206,6 +201,7 @@ EXPORT_API int connection_destroy(connection_h connection)
        g_free(connection);
        connection = NULL;
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -213,10 +209,13 @@ EXPORT_API int connection_create_cs(int tid, connection_h *connection)
 {
        int rv;
 
+       CONN_LOCK;
+
        rv = connection_create(connection);
        if (rv == CONNECTION_ERROR_NONE)
                _connection_set_cs_tid(tid, *connection);
 
+       CONN_UNLOCK;
        return rv;
 }
 
@@ -224,9 +223,12 @@ EXPORT_API int connection_destroy_cs(int tid, connection_h connection)
 {
        int rv;
 
+       CONN_LOCK;
+
        _connection_unset_cs_tid(tid, connection);
        rv = connection_destroy(connection);
 
+       CONN_UNLOCK;
        return rv;
 }
 
@@ -235,16 +237,20 @@ EXPORT_API int connection_get_type(connection_h connection, connection_type_e* t
        int rv = 0;
        int status = 0;
 
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (type == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        rv = vconf_get_int(VCONFKEY_NETWORK_STATUS, &status);
        if (rv != VCONF_OK) {
                CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d", status); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
@@ -252,16 +258,20 @@ EXPORT_API int connection_get_type(connection_h connection, connection_type_e* t
 
        *type = __connection_convert_net_state(status);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_get_ip_address(connection_h connection,
                                connection_address_family_e address_family, char** ip_address)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (ip_address == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -274,24 +284,30 @@ EXPORT_API int connection_get_ip_address(connection_h connection,
                break;
        default:
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        if (*ip_address == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;//LCOV_EXCL_LINE
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_get_proxy(connection_h connection,
                                connection_address_family_e address_family, char** proxy)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (proxy == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -302,14 +318,17 @@ EXPORT_API int connection_get_proxy(connection_h connection,
                break;
        default:
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        if (*proxy == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -318,6 +337,8 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
        FILE *fp;
        char buf[CONNECTION_MAC_INFO_LENGTH + 1];
 
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, ETHERNET_FEATURE);
 
        if (type == CONNECTION_TYPE_WIFI)
@@ -327,6 +348,7 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
 
        if (mac_addr == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -345,12 +367,14 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
                        fp = fopen(WIFI_MAC_INFO_FILE, "r");
                        if (fp == NULL) {
                                CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
+                               CONN_UNLOCK;
                                return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
                        }
 
                        if (fgets(buf, sizeof(buf), fp) == NULL) {
                                CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
                                fclose(fp); //LCOV_EXCL_LINE
+                               CONN_UNLOCK;
                                return CONNECTION_ERROR_OPERATION_FAILED;
                        }
 
@@ -360,6 +384,7 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
                        if (*mac_addr == NULL) {
                                CONNECTION_LOG(CONNECTION_ERROR, "malloc() failed"); //LCOV_EXCL_LINE
                                fclose(fp); //LCOV_EXCL_LINE
+                               CONN_UNLOCK;
                                return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
                        }
                        g_strlcpy(*mac_addr, buf, CONNECTION_MAC_INFO_LENGTH + 1);
@@ -369,6 +394,7 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
 
                        if (*mac_addr == NULL) {
                                CONNECTION_LOG(CONNECTION_ERROR, "Failed to get vconf from %s", VCONFKEY_WIFI_BSSID_ADDRESS); //LCOV_EXCL_LINE
+                               CONN_UNLOCK;
                                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
                        }
                }
@@ -378,12 +404,14 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
                fp = fopen(ETHERNET_MAC_INFO_FILE, "r");
                if (fp == NULL) {
                        CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", ETHERNET_MAC_INFO_FILE);
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_OUT_OF_MEMORY;
                }
 
                if (fgets(buf, sizeof(buf), fp) == NULL) {
                        CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", ETHERNET_MAC_INFO_FILE);
                        fclose(fp);
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_OPERATION_FAILED;
                }
 
@@ -393,6 +421,7 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
                if (*mac_addr == NULL) {
                        CONNECTION_LOG(CONNECTION_ERROR, "malloc() failed");
                        fclose(fp);
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_OUT_OF_MEMORY;
                }
 
@@ -403,6 +432,7 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
        //LCOV_EXCL_STOP
        default:
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
@@ -410,31 +440,38 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
        if ((strcmp(*mac_addr, "00:00:00:00:00:00") == 0) ||
                        (strcmp(*mac_addr, "ff:ff:ff:ff:ff:ff") == 0)) {
                CONNECTION_LOG(CONNECTION_ERROR, "MAC Address(%s) is invalid", *mac_addr); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
        }
 
        CONNECTION_LOG(CONNECTION_INFO, "MAC Address %s", *mac_addr);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 
 EXPORT_API int connection_is_metered_network(connection_h connection, bool* is_metered)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (is_metered == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        int rv = _connection_libnet_get_metered_state(connection, is_metered);
        if (rv != CONNECTION_ERROR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Fail to get metered state[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return rv; //LCOV_EXCL_LINE
        }
 
        CONNECTION_LOG(CONNECTION_INFO, "metered state: %s", is_metered ? "true" : "false");
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -448,16 +485,20 @@ EXPORT_API int connection_get_cellular_state(connection_h connection, connection
        int sim_id = 0;
 #endif
 
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (state == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_STATE, &status);
        if (rv != VCONF_OK) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular state"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
@@ -470,6 +511,7 @@ EXPORT_API int connection_get_cellular_state(connection_h connection, connection
                if (rv != VCONF_OK) {
                        CONNECTION_LOG(CONNECTION_ERROR,
                                        "Failed to get default subscriber id", sim_id);
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_OPERATION_FAILED;
                }
 
@@ -486,11 +528,13 @@ EXPORT_API int connection_get_cellular_state(connection_h connection, connection
 
                default:
                        CONNECTION_LOG(CONNECTION_ERROR, "Invalid subscriber id:%d", sim_id);
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_OPERATION_FAILED;
                }
 #endif
                if (rv != VCONF_OK) {
                        CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular state"); //LCOV_EXCL_LINE
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
                }
        }
@@ -502,195 +546,296 @@ EXPORT_API int connection_get_cellular_state(connection_h connection, connection
                        cellular_state == VCONFKEY_DNET_TRANSFER)
                *state = CONNECTION_CELLULAR_STATE_CONNECTED;
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (state == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        int rv = _connection_libnet_get_wifi_state(connection, state);
        if (rv != CONNECTION_ERROR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Fail to get Wi-Fi state[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return rv; //LCOV_EXCL_LINE
        }
 
        CONNECTION_LOG(CONNECTION_INFO, "Wi-Fi state: %d", *state);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 //LCOV_EXCL_START
 EXPORT_API int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e *state)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
 
        if (state == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return _connection_libnet_get_ethernet_state(connection, state);
+       int rv = _connection_libnet_get_ethernet_state(connection, state);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to get ethernet state[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_get_ethernet_cable_state(connection_h connection, connection_ethernet_cable_state_e *state)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
 
        if (state == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return _connection_libnet_get_ethernet_cable_state(connection, state);
+       int rv = _connection_libnet_get_ethernet_cable_state(connection, state);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to get ethernet cable state[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_set_ethernet_cable_state_chaged_cb(connection_h connection,
                          connection_ethernet_cable_state_chaged_cb callback, void *user_data)
 {
        DEPRECATED_LOG(__FUNCTION__, "connection_set_ethernet_cable_state_changed_cb");
+
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
 
        if (callback == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        DEPRECATED_LOG("connection_ethernet_cable_state_chaged_cb",
                        "connection_ethernet_cable_state_changed_cb");
 
-       return __connection_set_ethernet_cable_state_changed_cb(connection, callback, user_data);
+       __connection_set_ethernet_cable_state_changed_cb(connection, callback, user_data);
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_unset_ethernet_cable_state_chaged_cb(connection_h connection)
 {
        DEPRECATED_LOG(__FUNCTION__, "connection_unset_ethernet_cable_state_changed_cb");
+
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return __connection_set_ethernet_cable_state_changed_cb(connection, NULL, NULL);
+       __connection_set_ethernet_cable_state_changed_cb(connection, NULL, NULL);
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_set_ethernet_cable_state_changed_cb(connection_h connection,
                          connection_ethernet_cable_state_changed_cb callback, void *user_data)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
 
        if (callback == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return __connection_set_ethernet_cable_state_changed_cb(connection, callback, user_data);
+       __connection_set_ethernet_cable_state_changed_cb(connection, callback, user_data);
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_unset_ethernet_cable_state_changed_cb(connection_h connection)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return __connection_set_ethernet_cable_state_changed_cb(connection, NULL, NULL);
+       __connection_set_ethernet_cable_state_changed_cb(connection, NULL, NULL);
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 //LCOV_EXCL_STOP
 
 EXPORT_API int connection_get_bt_state(connection_h connection, connection_bt_state_e *state)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TETHERING_BLUETOOTH_FEATURE);
 
        if (state == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return _connection_libnet_get_bluetooth_state(connection, state);
+       int rv = _connection_libnet_get_bluetooth_state(connection, state);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to get bluetooth state[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_set_type_changed_cb(connection_h connection,
                                        connection_type_changed_cb callback, void* user_data)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (callback == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return __connection_set_type_changed_callback(connection, callback, user_data);
+       __connection_set_type_changed_callback(connection, callback, user_data);
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_unset_type_changed_cb(connection_h connection)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return __connection_set_type_changed_callback(connection, NULL, NULL);
+       __connection_set_type_changed_callback(connection, NULL, NULL);
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_set_ip_address_changed_cb(connection_h connection,
                                connection_address_changed_cb callback, void* user_data)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (callback == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return __connection_set_ip_changed_callback(connection, callback, user_data);
+       __connection_set_ip_changed_callback(connection, callback, user_data);
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_unset_ip_address_changed_cb(connection_h connection)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return __connection_set_ip_changed_callback(connection, NULL, NULL);
+       __connection_set_ip_changed_callback(connection, NULL, NULL);
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_set_proxy_address_changed_cb(connection_h connection,
                                connection_address_changed_cb callback, void* user_data)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (callback == NULL || !(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return __connection_set_proxy_changed_callback(connection, callback, user_data);
+       __connection_set_proxy_changed_callback(connection, callback, user_data);
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_unset_proxy_address_changed_cb(connection_h connection)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return __connection_set_proxy_changed_callback(connection, NULL, NULL);
+       __connection_set_proxy_changed_callback(connection, NULL, NULL);
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_add_profile(connection_h connection, connection_profile_h profile)
@@ -699,22 +844,27 @@ EXPORT_API int connection_add_profile(connection_h connection, connection_profil
        connection_handle_s *conn_handle = (connection_handle_s *)connection;
        net_profile_info_t *profile_info = (net_profile_info_t *)profile;
 
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
            !(_connection_libnet_check_profile_validity(profile))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        if (profile_info->ProfileInfo.Pdp.PSModemPath[0] != '/' ||
                        strlen(profile_info->ProfileInfo.Pdp.PSModemPath) < 2) {
                CONNECTION_LOG(CONNECTION_ERROR, "Modem object path is NULL"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
@@ -722,12 +872,15 @@ EXPORT_API int connection_add_profile(connection_h connection, connection_profil
                                profile_info->ProfileInfo.Pdp.ServiceType, profile_info);
        if (rv == NET_ERR_ACCESS_DENIED) {
                CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to add profile[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -737,11 +890,14 @@ EXPORT_API int connection_remove_profile(connection_h connection, connection_pro
        connection_handle_s *conn_handle = (connection_handle_s *)connection;
        net_profile_info_t *profile_info = (net_profile_info_t *)profile;
 
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
                !(_connection_libnet_check_profile_validity(profile))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -749,18 +905,22 @@ EXPORT_API int connection_remove_profile(connection_h connection, connection_pro
                profile_info->profile_type != NET_DEVICE_MESH &&
            profile_info->profile_type != NET_DEVICE_WIFI) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        rv = net_delete_profile(conn_handle->network_info_handle, profile_info->ProfileName);
        if (rv == NET_ERR_ACCESS_DENIED) {
                CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to delete profile[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -770,11 +930,14 @@ EXPORT_API int connection_update_profile(connection_h connection, connection_pro
        connection_handle_s *conn_handle = (connection_handle_s *)connection;
        net_profile_info_t *profile_info = (net_profile_info_t *)profile;
 
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
            !(_connection_libnet_check_profile_validity(profile))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -782,18 +945,23 @@ EXPORT_API int connection_update_profile(connection_h connection, connection_pro
                        profile_info->ProfileName, (net_profile_info_t*)profile);
        if (rv == NET_ERR_ACCESS_DENIED) {
                CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to modify profile[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_get_profile_iterator(connection_h connection,
                connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
@@ -801,77 +969,136 @@ EXPORT_API int connection_get_profile_iterator(connection_h connection,
             type != CONNECTION_ITERATOR_TYPE_CONNECTED &&
             type != CONNECTION_ITERATOR_TYPE_DEFAULT)) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return _connection_libnet_get_profile_iterator(connection, type, profile_iterator);
+       int rv = _connection_libnet_get_profile_iterator(connection, type, profile_iterator);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to get profile iterator [%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator,
                                                        connection_profile_h* profile)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
-       return _connection_libnet_get_iterator_next(profile_iterator, profile);
+       int rv = _connection_libnet_get_iterator_next(profile_iterator, profile);
+
+       CONN_UNLOCK;
+       return rv;
 }
 
 EXPORT_API bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
-       return _connection_libnet_iterator_has_next(profile_iterator);
+       int rv = _connection_libnet_iterator_has_next(profile_iterator);
+
+       CONN_UNLOCK;
+       return rv;
 }
 
 EXPORT_API int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
-       return _connection_libnet_destroy_iterator(profile_iterator);
+       int rv = _connection_libnet_destroy_iterator(profile_iterator);
+
+       CONN_UNLOCK;
+       return rv;
 }
 
 EXPORT_API int connection_get_current_profile(connection_h connection, connection_profile_h* profile)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) || profile == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return _connection_libnet_get_current_profile(connection, profile);
+       int rv = _connection_libnet_get_current_profile(connection, profile);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to get current profile [%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_get_default_cellular_service_profile(
                connection_h connection, connection_cellular_service_type_e type,
                connection_profile_h *profile)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) || profile == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return _connection_libnet_get_cellular_service_profile(connection, type, profile);
+       int rv = _connection_libnet_get_cellular_service_profile(connection, type, profile);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to get default cellular service profile [%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_set_default_cellular_service_profile(connection_h connection,
                connection_cellular_service_type_e type, connection_profile_h profile)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) || profile == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return _connection_libnet_set_cellular_service_profile_sync(connection, type, profile);
+       int rv = _connection_libnet_set_cellular_service_profile_sync(connection, type, profile);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to set default cellular service profile [%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_set_default_cellular_service_profile_async(connection_h connection,
                connection_cellular_service_type_e type, connection_profile_h profile,
                connection_set_default_cb callback, void* user_data)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        int rv;
@@ -879,26 +1106,32 @@ EXPORT_API int connection_set_default_cellular_service_profile_async(connection_
        if (!(__connection_check_handle_validity(connection)) ||
            profile == NULL || callback == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        rv = _connection_libnet_set_cellular_service_profile_async(connection, type, profile);
        if (rv == NET_ERR_ACCESS_DENIED) {
                CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to set default cellular service profile[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
        __connection_set_default_cellular_service_profile_callback(connection, callback, user_data);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_open_profile(connection_h connection, connection_profile_h profile,
                                        connection_opened_cb callback, void* user_data)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE);
 
        int rv;
@@ -906,26 +1139,32 @@ EXPORT_API int connection_open_profile(connection_h connection, connection_profi
        if (!(__connection_check_handle_validity(connection)) ||
            profile == NULL || callback == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        rv = _connection_libnet_open_profile(connection, profile);
        if (rv == NET_ERR_ACCESS_DENIED) {
                CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to open profile[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
        __connection_open_profile_set_callback(connection, callback, user_data);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_close_profile(connection_h connection, connection_profile_h profile,
                                        connection_closed_cb callback, void* user_data)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE);
 
        int rv;
@@ -933,110 +1172,167 @@ EXPORT_API int connection_close_profile(connection_h connection, connection_prof
        if (!(__connection_check_handle_validity(connection)) ||
            profile == NULL || callback == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        rv = _connection_libnet_close_profile(connection, profile);
        if (rv == NET_ERR_ACCESS_DENIED) {
                CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to close profile[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
        __connection_close_profile_set_callback(connection, callback, user_data);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_reset_profile(connection_h connection,
                                connection_reset_option_e type, int id, connection_reset_cb callback, void *user_data)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        int rv;
 
        if (!(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        if (id < 0 || id > 1) {
                CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        rv = _connection_libnet_reset_profile(connection, type, id);
        if (rv == NET_ERR_ACCESS_DENIED) {
                CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to reset profile[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
        __connection_reset_profile_set_callback(connection, callback, user_data);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_add_route(connection_h connection, const char* interface_name, const char* host_address)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
            interface_name == NULL || host_address == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return _connection_libnet_add_route(connection, interface_name, host_address);
+       int rv = _connection_libnet_add_route(connection, interface_name, host_address);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to add route [%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_remove_route(connection_h connection, const char* interface_name, const char* host_address)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
            interface_name == NULL || host_address == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return _connection_libnet_remove_route(connection, interface_name, host_address);
+       int rv = _connection_libnet_remove_route(connection, interface_name, host_address);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to remove route [%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_add_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
            interface_name == NULL || host_address == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return _connection_libnet_add_route_ipv6(connection, interface_name, host_address, gateway);
+       int rv = _connection_libnet_add_route_ipv6(connection, interface_name, host_address, gateway);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to add route ipv6 [%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_remove_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
            interface_name == NULL || host_address == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return _connection_libnet_remove_route_ipv6(connection, interface_name, host_address, gateway);
+       int rv = _connection_libnet_remove_route_ipv6(connection, interface_name, host_address, gateway);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to remove route ipv6 [%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_add_route_entry(connection_h connection,
                connection_address_family_e address_family,     const char *interface_name,
                const char *host_address, const char *gateway)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
@@ -1044,16 +1340,23 @@ EXPORT_API int connection_add_route_entry(connection_h connection,
             address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
            interface_name == NULL || host_address == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
-               return _connection_libnet_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4,
+       if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
+               int rv = _connection_libnet_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4,
                                                                interface_name, host_address, gateway);
-       else
-               return _connection_libnet_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6,
+               CONN_UNLOCK;
+               return rv;
+       } else {
+               int rv = _connection_libnet_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6,
                                                                interface_name, host_address, gateway);
+               CONN_UNLOCK;
+               return rv;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -1061,6 +1364,8 @@ EXPORT_API int connection_remove_route_entry(connection_h connection,
                connection_address_family_e address_family,     const char *interface_name,
                const char *host_address, const char *gateway)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
@@ -1068,16 +1373,23 @@ EXPORT_API int connection_remove_route_entry(connection_h connection,
             address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
            interface_name == NULL || host_address == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
-               return _connection_libnet_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4,
+       if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
+               int rv = _connection_libnet_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4,
                                                                interface_name, host_address, gateway);
-       else
-               return _connection_libnet_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6,
+               CONN_UNLOCK;
+               return rv;
+       } else {
+               int rv = _connection_libnet_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6,
                                                                interface_name, host_address, gateway);
+               CONN_UNLOCK;
+               return rv;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -1269,6 +1581,8 @@ EXPORT_API int connection_get_statistics(connection_h connection,
                                connection_type_e connection_type,
                                connection_statistics_type_e statistics_type, long long* size)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
 
        if (connection_type == CONNECTION_TYPE_CELLULAR)
@@ -1278,16 +1592,27 @@ EXPORT_API int connection_get_statistics(connection_h connection,
 
        if (!(__connection_check_handle_validity(connection)) || size == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return __get_statistic(connection, connection_type, statistics_type, size);
+       int rv = __get_statistic(connection, connection_type, statistics_type, size);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to get statistics [%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_reset_statistics(connection_h connection,
                                connection_type_e connection_type,
                                connection_statistics_type_e statistics_type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
 
        if (connection_type == CONNECTION_TYPE_CELLULAR)
@@ -1297,16 +1622,27 @@ EXPORT_API int connection_reset_statistics(connection_h connection,
 
        if (!__connection_check_handle_validity(connection)) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       return __reset_statistic(connection, connection_type, statistics_type);
+       int rv = __reset_statistic(connection, connection_type, statistics_type);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to get statistics [%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_foreach_ipv6_address(connection_h connection,
                connection_type_e connection_type, connection_ipv6_address_cb callback,
                void *user_data)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
@@ -1314,6 +1650,7 @@ EXPORT_API int connection_foreach_ipv6_address(connection_h connection,
 
        if (!(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1338,12 +1675,14 @@ EXPORT_API int connection_foreach_ipv6_address(connection_h connection,
                break;
        default:
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        if (rv != NET_ERR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "net_get_multiple_id_address"
                                " Failed = %d\n", rv);
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
        }
 
@@ -1357,6 +1696,7 @@ EXPORT_API int connection_foreach_ipv6_address(connection_h connection,
        g_slist_free_full(ipv6_address_list, g_free);
        ipv6_address_list = NULL;
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -1364,17 +1704,22 @@ EXPORT_API int connection_profile_start_tcpdump(connection_h connection)
 {
        int ret = 0;
 
+       CONN_LOCK;
+
        if (!(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        ret = _connection_libnet_start_tcpdump(connection);
        if (ret != CONNECTION_ERROR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to start tcpdump (%d)", ret);
+               CONN_UNLOCK;
                return ret;
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -1382,17 +1727,22 @@ EXPORT_API int connection_profile_stop_tcpdump(connection_h connection)
 {
        int ret = 0;
 
+       CONN_LOCK;
+
        if (!(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        ret = _connection_libnet_stop_tcpdump(connection);
        if (ret != CONNECTION_ERROR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to stop tcpdump (%d)", ret);
+               CONN_UNLOCK;
                return ret;
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -1400,16 +1750,21 @@ EXPORT_API int connection_profile_get_tcpdump_state(connection_h connection, gbo
 {
        int ret = 0;
 
+       CONN_LOCK;
+
        if (!(__connection_check_handle_validity(connection)) || !tcpdump_state) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        ret = _connection_libnet_get_tcpdump_state(connection, tcpdump_state);
        if (ret != CONNECTION_ERROR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to get the tcpdump state (%d)", ret);
+               CONN_UNLOCK;
                return ret;
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
index ead6124..4955d48 100755 (executable)
@@ -242,6 +242,8 @@ net_state_type_t _connection_profile_convert_to_net_state(connection_profile_sta
 /* Connection profile ********************************************************/
 EXPORT_API int connection_profile_create(connection_profile_type_e type, const char* keyword, connection_profile_h* profile)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
 
        if (type == CONNECTION_PROFILE_TYPE_CELLULAR)
@@ -252,30 +254,37 @@ EXPORT_API int connection_profile_create(connection_profile_type_e type, const c
        if (type != CONNECTION_PROFILE_TYPE_CELLULAR &&
             type != CONNECTION_PROFILE_TYPE_WIFI) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        if (profile == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        int rv  = _connection_libnet_check_profile_privilege();
-       if (rv == CONNECTION_ERROR_PERMISSION_DENIED)
+       if (rv == CONNECTION_ERROR_PERMISSION_DENIED) {
+               CONN_UNLOCK;
                return rv;
-       else if (rv != CONNECTION_ERROR_NONE) {
+       else if (rv != CONNECTION_ERROR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to create profile"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
        net_profile_info_t *profile_info = g_try_malloc0(sizeof(net_profile_info_t));
-       if (profile_info == NULL)
+       if (profile_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
        if (type == CONNECTION_PROFILE_TYPE_CELLULAR) {
                if (keyword == NULL) {
                        CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
                        g_free(profile_info);
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_INVALID_PARAMETER;
                }
                __profile_init_cellular_profile(profile_info, keyword);
@@ -286,72 +295,94 @@ EXPORT_API int connection_profile_create(connection_profile_type_e type, const c
        *profile = (connection_profile_h)profile_info;
        _connection_libnet_add_to_profile_list(*profile);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_destroy(connection_profile_h profile)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        _connection_libnet_remove_from_profile_list(profile);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_clone(connection_profile_h* cloned_profile, connection_profile_h origin_profile)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(origin_profile)) || cloned_profile == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        *cloned_profile = g_try_malloc0(sizeof(net_profile_info_t));
-       if (*cloned_profile == NULL)
+       if (*cloned_profile == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
        memcpy(*cloned_profile, origin_profile, sizeof(net_profile_info_t));
        _connection_libnet_add_to_profile_list(*cloned_profile);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_id(connection_profile_h profile, char** profile_id)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || profile_id == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
 
        char *prof_id = strrchr(profile_info->ProfileName, '/');
-       if (prof_id == NULL)
+       if (prof_id == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        prof_id++;
        *profile_id = g_strdup(prof_id);
 
-       if (*profile_id == NULL)
+       if (*profile_id == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_name(connection_profile_h profile, char** profile_name)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || profile_name == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -369,8 +400,10 @@ EXPORT_API int connection_profile_get_name(connection_profile_h profile, char**
                break; //LCOV_EXCL_LINE
        case NET_DEVICE_BLUETOOTH: {
                char *bt_name = strrchr(profile_info->ProfileName, '/');
-               if (bt_name == NULL)
+               if (bt_name == NULL) {
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_INVALID_PARAMETER;
+               }
 
                bt_name++;
                *profile_name = g_strdup(bt_name);
@@ -379,21 +412,28 @@ EXPORT_API int connection_profile_get_name(connection_profile_h profile, char**
                *profile_name = g_strdup(profile_info->ProfileInfo.Mesh.essid);
                break;
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       if (*profile_name == NULL)
+       if (*profile_name == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_type(connection_profile_h profile, connection_profile_type_e *type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -417,30 +457,40 @@ EXPORT_API int connection_profile_get_type(connection_profile_h profile, connect
                break;
        default:
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid profile type");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_network_interface_name(connection_profile_h profile, char** interface_name)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || interface_name == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        *interface_name = g_strdup(net_info->DevName);
-       if (*interface_name == NULL)
+       if (*interface_name == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -448,10 +498,13 @@ EXPORT_API int connection_profile_refresh(connection_profile_h profile)
 {
        int rv;
 
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -461,29 +514,36 @@ EXPORT_API int connection_profile_refresh(connection_profile_h profile)
        rv = net_get_profile_info(NULL, profile_info->ProfileName, &profile_info_local);
        if (rv == NET_ERR_ACCESS_DENIED) {
                CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to get profile information"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
        memcpy(profile, &profile_info_local, sizeof(net_profile_info_t));
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_state(connection_profile_h profile, connection_profile_state_e* state)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || state == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        *state = _profile_convert_to_cp_state(profile_info->ProfileState);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -492,6 +552,8 @@ EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profil
 {
        net_ip_config_type_t profile_type;
 
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
@@ -499,13 +561,16 @@ EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profil
             address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
            type == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
                profile_type = net_info->IpConfigType;
@@ -535,6 +600,7 @@ EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profil
                        *type = CONNECTION_IP_CONFIG_TYPE_NONE;
                        break;
                default:
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_OPERATION_FAILED;
                //LCOV_EXCL_STOP
                }
@@ -554,18 +620,22 @@ EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profil
                        break;
 
                default:
+                       CONN_UNLOCK;
                        return  CONNECTION_ERROR_OPERATION_FAILED;
 
                }
                //LCOV_EXCL_STOP
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_ip_address(connection_profile_h profile,
                connection_address_family_e address_family, char** ip_address)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
@@ -573,13 +643,16 @@ EXPORT_API int connection_profile_get_ip_address(connection_profile_h profile,
             address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
            ip_address == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
                *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr,
@@ -592,15 +665,20 @@ EXPORT_API int connection_profile_get_ip_address(connection_profile_h profile,
                }
        }
 
-       if (*ip_address == NULL)
+       if (*ip_address == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile,
                connection_address_family_e address_family, char** subnet_mask)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
@@ -608,32 +686,41 @@ EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile,
             address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
            subnet_mask == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
                CONNECTION_LOG(CONNECTION_ERROR,
                                "Please uses connection_profile_get_prefix_length()");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_NOT_SUPPORTED;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        *subnet_mask = __profile_convert_ip_to_string(&net_info->SubnetMask,
                                address_family);
 
-       if (*subnet_mask == NULL)
+       if (*subnet_mask == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_gateway_address(connection_profile_h profile,
                connection_address_family_e address_family, char** gateway_address)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
@@ -641,13 +728,16 @@ EXPORT_API int connection_profile_get_gateway_address(connection_profile_h profi
             address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
            gateway_address == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
                *gateway_address = __profile_convert_ip_to_string(
@@ -656,9 +746,12 @@ EXPORT_API int connection_profile_get_gateway_address(connection_profile_h profi
                *gateway_address = __profile_convert_ip_to_string(
                                        &net_info->GatewayAddr, address_family);
 
-       if (*gateway_address == NULL)
+       if (*gateway_address == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -666,10 +759,13 @@ EXPORT_API int connection_profile_get_dhcp_server_address(
                connection_profile_h profile,
                connection_address_family_e address_family, char** dhcp_server)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
                CONNECTION_LOG(CONNECTION_ERROR, "Not supported");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
        }
 
@@ -677,13 +773,16 @@ EXPORT_API int connection_profile_get_dhcp_server_address(
            (address_family != CONNECTION_ADDRESS_FAMILY_IPV4) ||
            dhcp_server == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        CONNECTION_LOG(CONNECTION_INFO, "IP Config %d, DHCP Server Address %s",
                        net_info->IpConfigType, (net_info->BServerAddr ? "TRUE" : "FALSE"));
@@ -691,9 +790,12 @@ EXPORT_API int connection_profile_get_dhcp_server_address(
        *dhcp_server = __profile_convert_ip_to_string(&net_info->ServerAddr,
                        address_family);
 
-       if (*dhcp_server == NULL)
+       if (*dhcp_server == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -701,6 +803,8 @@ EXPORT_API int connection_profile_get_dhcp_lease_duration(
                connection_profile_h profile,
                connection_address_family_e address_family, int* dhcp_lease_duration)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
@@ -708,30 +812,37 @@ EXPORT_API int connection_profile_get_dhcp_lease_duration(
                address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
                dhcp_lease_duration == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
                CONNECTION_LOG(CONNECTION_ERROR, "Not supported");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        CONNECTION_LOG(CONNECTION_INFO, "Lease duration : %d",
                        net_info->DHCPLeaseDuration);
 
        *dhcp_lease_duration = net_info->DHCPLeaseDuration;
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_dns_address(connection_profile_h profile, int order,
                connection_address_family_e address_family, char** dns_address)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
@@ -741,13 +852,16 @@ EXPORT_API int connection_profile_get_dns_address(connection_profile_h profile,
            order <= 0 ||
            order > NET_DNS_ADDR_MAX) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
                *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr[order-1],
@@ -756,25 +870,33 @@ EXPORT_API int connection_profile_get_dns_address(connection_profile_h profile,
                *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr6[order-1], //LCOV_EXCL_LINE
                                address_family);
 
-       if (*dns_address == NULL)
+       if (*dns_address == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_proxy_type(connection_profile_h profile, connection_proxy_type_e *type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        //LCOV_EXCL_START
        if (profile_info->profile_type == NET_DEVICE_ETHERNET) {
@@ -786,6 +908,7 @@ EXPORT_API int connection_profile_get_proxy_type(connection_profile_h profile, c
                        free(proxy);
                }
 
+               CONN_UNLOCK;
                return CONNECTION_ERROR_NONE;
        }
        //LCOV_EXCL_STOP
@@ -803,16 +926,20 @@ EXPORT_API int connection_profile_get_proxy_type(connection_profile_h profile, c
                break;
        case NET_PROXY_TYPE_UNKNOWN:
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
        //LCOV_EXCL_STOP
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_proxy_address(connection_profile_h profile,
                connection_address_family_e address_family, char** proxy_address)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
@@ -820,19 +947,25 @@ EXPORT_API int connection_profile_get_proxy_address(connection_profile_h profile
             address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
             proxy_address == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        *proxy_address = g_strdup(net_info->ProxyAddr);
 
-       if (*proxy_address == NULL)
+       if (*proxy_address == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -841,19 +974,24 @@ EXPORT_API int connection_profile_set_ip_config_type(connection_profile_h profil
 {
        net_ip_config_type_t *profile_type = NULL;
 
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
            (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
             address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
                profile_type = &net_info->IpConfigType ;
@@ -887,6 +1025,7 @@ EXPORT_API int connection_profile_set_ip_config_type(connection_profile_h profil
                        break;
 
                default:
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_INVALID_PARAMETER;
                //LCOV_EXCL_STOP
                }
@@ -910,124 +1049,156 @@ EXPORT_API int connection_profile_set_ip_config_type(connection_profile_h profil
                        break;
 
                default:
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_INVALID_PARAMETER;
                }
                //LCOV_EXCL_STOP
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_ip_address(connection_profile_h profile,
                connection_address_family_e address_family, const char* ip_address)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
            (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
             address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
                //LCOV_EXCL_START
                if (ip_address == NULL)
                        inet_pton(AF_INET6, "::", &net_info->IpAddr6.Data.Ipv6);
-               else if (inet_pton(AF_INET6, ip_address,
-                                       &net_info->IpAddr6.Data.Ipv6) < 1)
+               else if (inet_pton(AF_INET6, ip_address, &net_info->IpAddr6.Data.Ipv6) < 1) {
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_INVALID_PARAMETER;
+               }
                //LCOV_EXCL_STOP
        } else {
                if (ip_address == NULL)
                        net_info->IpAddr.Data.Ipv4.s_addr = 0;
-               else if (inet_pton(AF_INET, ip_address,
-                                       &net_info->IpAddr.Data.Ipv4) < 1)
+               else if (inet_pton(AF_INET, ip_address, &net_info->IpAddr.Data.Ipv4) < 1) {
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_INVALID_PARAMETER;
+               }
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_subnet_mask(connection_profile_h profile,
                connection_address_family_e address_family, const char* subnet_mask)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
                        (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
                         address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
                CONNECTION_LOG(CONNECTION_ERROR,
                                "Please uses connection_profile_set_prefix_length()");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_NOT_SUPPORTED;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (subnet_mask == NULL)
                net_info->SubnetMask.Data.Ipv4.s_addr = 0;
-       else if (inet_pton(AF_INET, subnet_mask , &net_info->SubnetMask.Data.Ipv4) < 1)
+       else if (inet_pton(AF_INET, subnet_mask , &net_info->SubnetMask.Data.Ipv4) < 1) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        net_info->PrefixLen = __profile_convert_netmask_to_prefix_len(subnet_mask);
        if (net_info->PrefixLen <= 0 || net_info->PrefixLen > 31) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid Prefix length: %d", net_info->PrefixLen);
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_gateway_address(connection_profile_h profile,
                connection_address_family_e address_family, const char* gateway_address)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
            (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
             address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
                //LCOV_EXCL_START
                if (gateway_address == NULL)
                        inet_pton(AF_INET6, "::", &net_info->GatewayAddr6.Data.Ipv6);
-               else if (inet_pton(AF_INET6, gateway_address, &net_info->GatewayAddr6.Data.Ipv6) < 1)
+               else if (inet_pton(AF_INET6, gateway_address, &net_info->GatewayAddr6.Data.Ipv6) < 1) {
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_INVALID_PARAMETER;
+               }
                //LCOV_EXCL_STOP
        } else {
                if (gateway_address == NULL)
                        net_info->GatewayAddr.Data.Ipv4.s_addr = 0;
-               else if (inet_pton(AF_INET, gateway_address, &(net_info->GatewayAddr.Data.Ipv4)) < 1)
+               else if (inet_pton(AF_INET, gateway_address, &(net_info->GatewayAddr.Data.Ipv4)) < 1) {
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_INVALID_PARAMETER;
+               }
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_dns_address(connection_profile_h profile, int order,
                connection_address_family_e address_family, const char* dns_address)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
@@ -1036,21 +1207,26 @@ EXPORT_API int connection_profile_set_dns_address(connection_profile_h profile,
            order <= 0 ||
            order > NET_DNS_ADDR_MAX) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
                //LCOV_EXCL_START
                net_info->DnsAddr6[order-1].Type = NET_ADDR_IPV6;
                if (dns_address == NULL)
                        inet_pton(AF_INET6, "::", &net_info->DnsAddr6[order-1].Data.Ipv6);
-               else if (inet_pton(AF_INET6, dns_address, &net_info->DnsAddr6[order-1].Data.Ipv6) < 1)
+               else if (inet_pton(AF_INET6, dns_address, &net_info->DnsAddr6[order-1].Data.Ipv6) < 1) {
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_INVALID_PARAMETER;
+               }
                if (net_info->DnsCount6 < order)
                        net_info->DnsCount6 = order;
                //LCOV_EXCL_STOP
@@ -1058,28 +1234,36 @@ EXPORT_API int connection_profile_set_dns_address(connection_profile_h profile,
                net_info->DnsAddr[order-1].Type = NET_ADDR_IPV4;
                if (dns_address == NULL)
                        net_info->DnsAddr[order-1].Data.Ipv4.s_addr = 0;
-               else if (inet_pton(AF_INET, dns_address, &(net_info->DnsAddr[order-1].Data.Ipv4)) < 1)
+               else if (inet_pton(AF_INET, dns_address, &(net_info->DnsAddr[order-1].Data.Ipv4)) < 1) {
+                       CONN_UNLOCK;
                        return CONNECTION_ERROR_INVALID_PARAMETER;
+               }
                if (net_info->DnsCount < order)
                        net_info->DnsCount = order;
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_proxy_type(connection_profile_h profile, connection_proxy_type_e type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        switch (type) {
        //LCOV_EXCL_START
@@ -1093,10 +1277,12 @@ EXPORT_API int connection_profile_set_proxy_type(connection_profile_h profile, c
                net_info->ProxyMethod = NET_PROXY_TYPE_MANUAL;
                break;
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        //LCOV_EXCL_STOP
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -1110,50 +1296,66 @@ EXPORT_API int connection_profile_set_proxy_address(connection_profile_h profile
            (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
             address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (proxy_address == NULL)
                net_info->ProxyAddr[0] = '\0';
        else
                g_strlcpy(net_info->ProxyAddr, proxy_address, NET_PROXY_LEN_MAX);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_state_changed_cb(connection_profile_h profile,
                connection_profile_state_changed_cb callback, void* user_data)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || callback == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       if (_connection_libnet_add_to_profile_cb_list(profile, callback, user_data))
+       if (_connection_libnet_add_to_profile_cb_list(profile, callback, user_data)) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_NONE;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
 }
 
 EXPORT_API int connection_profile_unset_state_changed_cb(connection_profile_h profile)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       if (_connection_libnet_remove_from_profile_cb_list(profile) != true)
+       if (_connection_libnet_remove_from_profile_cb_list(profile) != true) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -1161,129 +1363,164 @@ EXPORT_API int connection_profile_unset_state_changed_cb(connection_profile_h pr
 /* Wi-Fi profile *************************************************************/
 EXPORT_API int connection_profile_get_wifi_essid(connection_profile_h profile, char** essid)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || essid == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
 
        if (profile_info->profile_type != NET_DEVICE_WIFI &&
-                               profile_info->profile_type != NET_DEVICE_MESH)
+                               profile_info->profile_type != NET_DEVICE_MESH) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        if (profile_info->profile_type == NET_DEVICE_WIFI)
                *essid = g_strdup(profile_info->ProfileInfo.Wlan.essid);
        else
                *essid = g_strdup(profile_info->ProfileInfo.Mesh.essid);
 
-       if (*essid == NULL)
+       if (*essid == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_wifi_bssid(connection_profile_h profile, char** bssid)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || bssid == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
 
        if (profile_info->profile_type != NET_DEVICE_WIFI &&
-                               profile_info->profile_type != NET_DEVICE_MESH)
+                               profile_info->profile_type != NET_DEVICE_MESH) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        if (profile_info->profile_type == NET_DEVICE_WIFI)
                *bssid = g_strdup(profile_info->ProfileInfo.Wlan.bssid);
        else
                *bssid = g_strdup(profile_info->ProfileInfo.Mesh.bssid);
 
-       if (*bssid == NULL)
+       if (*bssid == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_wifi_rssi(connection_profile_h profile, int* rssi)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || rssi == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
 
        if (profile_info->profile_type != NET_DEVICE_WIFI &&
-                               profile_info->profile_type != NET_DEVICE_MESH)
+                               profile_info->profile_type != NET_DEVICE_MESH) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        if (profile_info->profile_type == NET_DEVICE_WIFI)
                *rssi = (int)profile_info->ProfileInfo.Wlan.Strength;
        else
                *rssi = (int)profile_info->ProfileInfo.Mesh.Strength;
 
-
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_wifi_frequency(connection_profile_h profile, int* frequency)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || frequency == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
 
        if (profile_info->profile_type != NET_DEVICE_WIFI &&
-                               profile_info->profile_type != NET_DEVICE_MESH)
+                               profile_info->profile_type != NET_DEVICE_MESH) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        if (profile_info->profile_type == NET_DEVICE_WIFI)
                *frequency = (int)profile_info->ProfileInfo.Wlan.frequency;
        else
                *frequency = (int)profile_info->ProfileInfo.Mesh.frequency;
 
-
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_wifi_max_speed(connection_profile_h profile, int* max_speed)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || max_speed == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
 
-       if (profile_info->profile_type != NET_DEVICE_WIFI)
+       if (profile_info->profile_type != NET_DEVICE_WIFI) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        *max_speed = profile_info->ProfileInfo.Wlan.max_rate;
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h profile, connection_wifi_security_type_e *type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1291,8 +1528,10 @@ EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h pr
 
        wlan_security_mode_type_t sec_mode;
        if (profile_info->profile_type != NET_DEVICE_WIFI &&
-                               profile_info->profile_type != NET_DEVICE_MESH)
+                               profile_info->profile_type != NET_DEVICE_MESH) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        if (profile_info->profile_type == NET_DEVICE_WIFI)
                sec_mode = profile_info->ProfileInfo.Wlan.security_info.sec_mode;
@@ -1320,26 +1559,33 @@ EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h pr
                *type = CONNECTION_WIFI_SECURITY_TYPE_SAE;
                break;
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
        //LCOV_EXCL_STOP
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_wifi_encryption_type(connection_profile_h profile, connection_wifi_encryption_type_e *type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
 
-       if (profile_info->profile_type != NET_DEVICE_WIFI)
+       if (profile_info->profile_type != NET_DEVICE_WIFI) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        switch (profile_info->ProfileInfo.Wlan.security_info.enc_mode) {
        //LCOV_EXCL_START
@@ -1359,19 +1605,24 @@ EXPORT_API int connection_profile_get_wifi_encryption_type(connection_profile_h
                *type = CONNECTION_WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED;
                break;
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
        //LCOV_EXCL_STOP
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_is_wifi_passphrase_required(connection_profile_h profile, bool* required)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || required == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1379,11 +1630,14 @@ EXPORT_API int connection_profile_is_wifi_passphrase_required(connection_profile
 
        wlan_security_mode_type_t sec_mode;
        if (profile_info->profile_type != NET_DEVICE_WIFI &&
-                               profile_info->profile_type != NET_DEVICE_MESH)
+                               profile_info->profile_type != NET_DEVICE_MESH) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        if (profile_info->Favourite) {
                *required = false;
+               CONN_UNLOCK;
                return CONNECTION_ERROR_NONE;
        }
 
@@ -1405,27 +1659,34 @@ EXPORT_API int connection_profile_is_wifi_passphrase_required(connection_profile
                *required = true;
                break;
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
        //LCOV_EXCL_STOP
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_wifi_passphrase(connection_profile_h profile, const char* passphrase)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || passphrase == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
 
        if (profile_info->profile_type != NET_DEVICE_WIFI &&
-                               profile_info->profile_type != NET_DEVICE_MESH)
+                               profile_info->profile_type != NET_DEVICE_MESH) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        if (profile_info->profile_type == NET_DEVICE_WIFI)
                g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.psk.pskKey,
@@ -1434,28 +1695,35 @@ EXPORT_API int connection_profile_set_wifi_passphrase(connection_profile_h profi
                g_strlcpy(profile_info->ProfileInfo.Mesh.security_info.authentication.sae.saeKey,
                                  passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_is_wifi_wps_supported(connection_profile_h profile, bool* supported)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || supported == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
 
-       if (profile_info->profile_type != NET_DEVICE_WIFI)
+       if (profile_info->profile_type != NET_DEVICE_WIFI) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
 
        if (profile_info->ProfileInfo.Wlan.security_info.wps_support)
                *supported = true;
        else
                *supported = false;
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
@@ -1464,10 +1732,13 @@ EXPORT_API int connection_profile_is_wifi_wps_supported(connection_profile_h pro
 EXPORT_API int connection_profile_get_cellular_service_type(connection_profile_h profile,
                                                connection_cellular_service_type_e* type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1475,6 +1746,7 @@ EXPORT_API int connection_profile_get_cellular_service_type(connection_profile_h
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1482,18 +1754,23 @@ EXPORT_API int connection_profile_get_cellular_service_type(connection_profile_h
 
        if (*type == CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid service type Passed"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_cellular_apn(connection_profile_h profile, char** apn)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || apn == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1501,24 +1778,31 @@ EXPORT_API int connection_profile_get_cellular_apn(connection_profile_h profile,
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        *apn = g_strdup(profile_info->ProfileInfo.Pdp.Apn);
-       if (*apn == NULL)
+       if (*apn == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h profile,
                connection_cellular_auth_type_e *type, char** user_name, char** password)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
            type == NULL || user_name == NULL || password == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1526,6 +1810,7 @@ EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h pr
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1541,29 +1826,37 @@ EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h pr
                *type = CONNECTION_CELLULAR_AUTH_TYPE_CHAP;
                break;
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
        //LCOV_EXCL_STOP
        }
 
        *user_name = g_strdup(profile_info->ProfileInfo.Pdp.AuthInfo.UserName);
-       if (*user_name == NULL)
+       if (*user_name == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
        *password = g_strdup(profile_info->ProfileInfo.Pdp.AuthInfo.Password);
        if (*password == NULL) {
                g_free(*user_name); //LCOV_EXCL_LINE
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_cellular_home_url(connection_profile_h profile, char** home_url)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || home_url == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1571,22 +1864,29 @@ EXPORT_API int connection_profile_get_cellular_home_url(connection_profile_h pro
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        *home_url = g_strdup(profile_info->ProfileInfo.Pdp.HomeURL);
-       if (*home_url == NULL)
+       if (*home_url == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_cellular_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e *type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1594,6 +1894,7 @@ EXPORT_API int connection_profile_get_cellular_pdn_type(connection_profile_h pro
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1612,19 +1913,24 @@ EXPORT_API int connection_profile_get_cellular_pdn_type(connection_profile_h pro
                *type = CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6;
                break;
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
        //LCOV_EXCL_STOP
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_cellular_roam_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e *type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1632,6 +1938,7 @@ EXPORT_API int connection_profile_get_cellular_roam_pdn_type(connection_profile_
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1650,19 +1957,24 @@ EXPORT_API int connection_profile_get_cellular_roam_pdn_type(connection_profile_
                *type = CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6;
                break;
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
        //LCOV_EXCL_STOP
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* is_roaming)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || is_roaming == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1670,6 +1982,7 @@ EXPORT_API int connection_profile_is_cellular_roaming(connection_profile_h profi
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1678,15 +1991,19 @@ EXPORT_API int connection_profile_is_cellular_roaming(connection_profile_h profi
        else
                *is_roaming = false;
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_is_cellular_hidden(connection_profile_h profile, bool* is_hidden)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || is_hidden == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1694,6 +2011,7 @@ EXPORT_API int connection_profile_is_cellular_hidden(connection_profile_h profil
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1702,15 +2020,19 @@ EXPORT_API int connection_profile_is_cellular_hidden(connection_profile_h profil
        else
                *is_hidden = false;
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_is_cellular_editable(connection_profile_h profile, bool* is_editable)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || is_editable == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1718,6 +2040,7 @@ EXPORT_API int connection_profile_is_cellular_editable(connection_profile_h prof
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1726,15 +2049,19 @@ EXPORT_API int connection_profile_is_cellular_editable(connection_profile_h prof
        else
                *is_editable = false;
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_is_cellular_default(connection_profile_h profile, bool* is_default)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || is_default == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1742,6 +2069,7 @@ EXPORT_API int connection_profile_is_cellular_default(connection_profile_h profi
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1750,16 +2078,20 @@ EXPORT_API int connection_profile_is_cellular_default(connection_profile_h profi
        else
                *is_default = false;
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_cellular_service_type(connection_profile_h profile,
                connection_cellular_service_type_e service_type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1767,6 +2099,7 @@ EXPORT_API int connection_profile_set_cellular_service_type(connection_profile_h
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1792,19 +2125,24 @@ EXPORT_API int connection_profile_set_cellular_service_type(connection_profile_h
                break;
        case CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN:
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        //LCOV_EXCL_STOP
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_cellular_apn(connection_profile_h profile, const char* apn)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || apn == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1812,22 +2150,27 @@ EXPORT_API int connection_profile_set_cellular_apn(connection_profile_h profile,
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        g_strlcpy(profile_info->ProfileInfo.Pdp.Apn, apn, NET_PDP_APN_LEN_MAX+1);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_cellular_auth_info(connection_profile_h profile,
                connection_cellular_auth_type_e type, const char* user_name, const char* password)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
            user_name == NULL || password == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1835,6 +2178,7 @@ EXPORT_API int connection_profile_set_cellular_auth_info(connection_profile_h pr
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1850,6 +2194,7 @@ EXPORT_API int connection_profile_set_cellular_auth_info(connection_profile_h pr
                profile_info->ProfileInfo.Pdp.AuthInfo.AuthType = NET_PDP_AUTH_CHAP;
                break;
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        //LCOV_EXCL_STOP
        }
@@ -1857,15 +2202,19 @@ EXPORT_API int connection_profile_set_cellular_auth_info(connection_profile_h pr
        g_strlcpy(profile_info->ProfileInfo.Pdp.AuthInfo.UserName, user_name, NET_PDP_AUTH_USERNAME_LEN_MAX+1);
        g_strlcpy(profile_info->ProfileInfo.Pdp.AuthInfo.Password, password, NET_PDP_AUTH_PASSWORD_LEN_MAX+1);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_cellular_home_url(connection_profile_h profile, const char* home_url)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) || home_url == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1873,20 +2222,25 @@ EXPORT_API int connection_profile_set_cellular_home_url(connection_profile_h pro
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        g_strlcpy(profile_info->ProfileInfo.Pdp.HomeURL, home_url, NET_HOME_URL_LEN_MAX);
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_cellular_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1894,6 +2248,7 @@ EXPORT_API int connection_profile_set_cellular_pdn_type(connection_profile_h pro
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1914,19 +2269,24 @@ EXPORT_API int connection_profile_set_cellular_pdn_type(connection_profile_h pro
                profile_info->ProfileInfo.Pdp.PdnType = NET_PDN_TYPE_IPV4_IPV6;
                break;
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        //LCOV_EXCL_STOP
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_cellular_roam_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1934,6 +2294,7 @@ EXPORT_API int connection_profile_set_cellular_roam_pdn_type(connection_profile_
 
        if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1954,40 +2315,51 @@ EXPORT_API int connection_profile_set_cellular_roam_pdn_type(connection_profile_
                profile_info->ProfileInfo.Pdp.RoamPdnType = NET_PDN_TYPE_IPV4_IPV6;
                break;
        default:
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        //LCOV_EXCL_STOP
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_ipv6_state(connection_profile_h profile, connection_profile_state_e *state)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile)) ||
                        state == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        *state = _profile_convert_to_cp_state(profile_info->ProfileState6);
-       if (*state < 0)
+       if (*state < 0) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_dns_config_type(connection_profile_h profile,
                connection_address_family_e address_family, connection_dns_config_type_e type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
        if (!(_connection_libnet_check_profile_validity(profile))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -1996,6 +2368,7 @@ EXPORT_API int connection_profile_set_dns_config_type(connection_profile_h profi
                        (type != CONNECTION_DNS_CONFIG_TYPE_STATIC &&
                         type != CONNECTION_DNS_CONFIG_TYPE_DYNAMIC)) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
@@ -2004,8 +2377,10 @@ EXPORT_API int connection_profile_set_dns_config_type(connection_profile_h profi
        net_profile_info_t *profile_info = profile;
 
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
                profileType = &net_info->DnsConfigType;
@@ -2019,12 +2394,15 @@ EXPORT_API int connection_profile_set_dns_config_type(connection_profile_h profi
                *profileType6 = type;
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_dns_config_type(connection_profile_h profile,
                connection_address_family_e address_family, connection_dns_config_type_e *type)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
@@ -2033,14 +2411,17 @@ EXPORT_API int connection_profile_get_dns_config_type(connection_profile_h profi
                         address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
                        type == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_dns_config_type_t profileType;
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
                profileType = net_info->DnsConfigType;
@@ -2059,12 +2440,15 @@ EXPORT_API int connection_profile_get_dns_config_type(connection_profile_h profi
                break;
        }
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_set_prefix_length(connection_profile_h profile,
                connection_address_family_e address_family, int prefix_len)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
@@ -2072,13 +2456,16 @@ EXPORT_API int connection_profile_set_prefix_length(connection_profile_h profile
                        (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
                        address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
                net_info->PrefixLen = prefix_len;
@@ -2086,12 +2473,15 @@ EXPORT_API int connection_profile_set_prefix_length(connection_profile_h profile
        } else
                net_info->PrefixLen6 = prefix_len;
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
 
 EXPORT_API int connection_profile_get_prefix_length(connection_profile_h profile,
                connection_address_family_e address_family, int *prefix_len)
 {
+       CONN_LOCK;
+
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
 
@@ -2100,18 +2490,22 @@ EXPORT_API int connection_profile_get_prefix_length(connection_profile_h profile
                        address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
                        prefix_len == NULL) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
        net_profile_info_t *profile_info = profile;
        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
+       if (net_info == NULL) {
+               CONN_UNLOCK;
                return CONNECTION_ERROR_OPERATION_FAILED;
+       }
 
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
                *prefix_len =  net_info->PrefixLen;
        else if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
                *prefix_len =  net_info->PrefixLen6;
 
+       CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
index ea5ce4b..b8f9c7b 100755 (executable)
@@ -26,6 +26,7 @@
 
 static GSList *prof_handle_list = NULL;
 static GHashTable *profile_cb_table = NULL;
+static pthread_mutex_t g_conn_thread_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 struct _profile_cb_s {
        connection_profile_state_changed_cb callback;
@@ -1545,3 +1546,13 @@ int _connection_libnet_get_tcpdump_state(connection_handle_s *conn_handle,
 
        return result;
 }
+
+void _connection_lock(void)
+{
+       pthread_mutex_lock(&g_conn_thread_mutex);
+}
+
+void _connection_unlock(void)
+{
+       pthread_mutex_unlock(&g_conn_thread_mutex);
+}