multi-thread: thread local storage support 69/16569/2
authorJaehyun Kim <jeik01.kim@samsung.com>
Wed, 19 Feb 2014 09:44:52 +0000 (18:44 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Wed, 19 Feb 2014 09:50:53 +0000 (18:50 +0900)
Change-Id: Id382194dbf5b4e54285b4eb3bdf8c43124f7425a

packaging/libnet-client.spec
src/include/network-internal.h
src/network-cm-intf.c
src/network-dbus-request.c
src/network-internal.c
src/network-profile-intf.c
src/network-signal-handler.c
src/network-wifi-intf.c

index 476a787f8737bf24345bdccb716524d8039b2c84..115ef8e398c3c0dff9b57ab87b681a5e5b11a709 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libnet-client
 Summary:    Network Client library (Shared library)
-Version:    0.1.77_50
+Version:    0.1.77_51
 Release:    1
 Group:      System/Network
 License:    Flora License
index eca3c11ce390f3e770129031417e4605dc21b102..06d59490c30e46c278733a0713c6ff432fa20c1d 100644 (file)
@@ -232,8 +232,6 @@ int _net_is_valid_service_type(net_service_type_t service_type);
 int _net_open_connection_with_wifi_info(const net_wifi_connection_info_t* wifi_info);
 int _net_check_profile_name(const char* ProfileName);
 int _net_get_profile_list(net_device_t device_type, net_profile_info_t** profile_info, int* profile_count);
-int _net_mutex_init(void);
-void _net_mutex_destroy(void);
 void _net_client_callback(net_event_info_t *event_data);
 int _net_get_service_profile(net_service_type_t service_type, net_profile_name_t *profile_name);
 int _net_get_default_profile_info(net_profile_info_t *profile_info);
index ffe119c8322f1d8647791579f9e4e2b70511ea24..dea8c70bbfc3d00e0a7baa1e6585c16ca595e3ab 100644 (file)
 /*****************************************************************************
  *     Extern Variables
  *****************************************************************************/
-extern network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
+extern __thread network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
 
 /*****************************************************************************
  *     Global Variables
  *****************************************************************************/
-network_info_t NetworkInfo = {0, };
+__thread network_info_t NetworkInfo = { 0, };
 
 static int __net_get_default_profile(void *param, net_profile_info_t *active_profile_info)
 {
@@ -36,7 +36,7 @@ static int __net_get_default_profile(void *param, net_profile_info_t *active_pro
 
        net_err_t Error = NET_ERR_NONE;
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -201,23 +201,16 @@ EXPORT_API int net_register_client(net_event_cb_t event_cb, void *user_data)
        }
 
        if (NetworkInfo.ClientEventCb != NULL) {
-               NETWORK_LOG(NETWORK_ERROR, "Application Already registered\n");
+               NETWORK_LOG(NETWORK_ERROR, "Application already registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_ALREADY_REGISTERED;
        }
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
-               if (_net_mutex_init() != NET_ERR_NONE) {
-                       __NETWORK_FUNC_EXIT__;
-                       return NET_ERR_UNKNOWN;
-               }
-
+       if (NetworkInfo.ref_count < 1) {
                Error = _net_register_signal();
                if (Error != NET_ERR_NONE && Error != NET_ERR_APP_ALREADY_REGISTERED) {
                        NETWORK_LOG(NETWORK_ERROR, "Failed to register DBus signal [%s]\n",
                                        _net_print_error(Error));
-                       _net_mutex_destroy();
-
                        __NETWORK_FUNC_EXIT__;
                        return Error;
                }
@@ -226,7 +219,7 @@ EXPORT_API int net_register_client(net_event_cb_t event_cb, void *user_data)
                _net_init_service_state_table();
        }
 
-       g_atomic_int_inc(&NetworkInfo.ref_count);
+       __sync_fetch_and_add(&NetworkInfo.ref_count, 1);
 
        NetworkInfo.ClientEventCb = event_cb;
        NetworkInfo.user_data = user_data;
@@ -264,15 +257,11 @@ EXPORT_API int net_register_client_ext(net_event_cb_t event_cb, net_device_t cli
                break;
        }
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
-               if (_net_mutex_init() != NET_ERR_NONE)
-                       return NET_ERR_UNKNOWN;
-
+       if (NetworkInfo.ref_count < 1) {
                Error = _net_register_signal();
                if (Error != NET_ERR_NONE && Error != NET_ERR_APP_ALREADY_REGISTERED) {
                        NETWORK_LOG(NETWORK_ERROR, "Failed to register DBus signal [%s]\n",
                                        _net_print_error(Error));
-                       _net_mutex_destroy();
                        return Error;
                }
 
@@ -280,7 +269,7 @@ EXPORT_API int net_register_client_ext(net_event_cb_t event_cb, net_device_t cli
                _net_init_service_state_table();
        }
 
-       g_atomic_int_inc(&NetworkInfo.ref_count);
+       __sync_fetch_and_add(&NetworkInfo.ref_count, 1);
 
        switch (client_type) {
        case NET_DEVICE_DEFAULT:
@@ -302,7 +291,7 @@ EXPORT_API int net_register_client_ext(net_event_cb_t event_cb, net_device_t cli
 /**
  * @fn  EXPORT_API int net_deregister_client(void)
  *
- * This function deregisters with network client 
+ * This function deregisters with network client
  * This is Sync API.
  *
  * @return       int - NET_ERR_NONE on success, negative values for errors
@@ -313,16 +302,15 @@ EXPORT_API int net_deregister_client(void)
 {
        __NETWORK_FUNC_ENTER__;
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0 ||
-           NetworkInfo.ClientEventCb == NULL) {
-               NETWORK_LOG(NETWORK_ERROR, "Application was not registered\n");
+       if (NetworkInfo.ref_count < 1 ||
+                       NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
        }
 
-       if (g_atomic_int_dec_and_test(&NetworkInfo.ref_count)) {
+       if (__sync_sub_and_fetch(&NetworkInfo.ref_count, 1) < 1) {
                _net_deregister_signal();
-               _net_mutex_destroy();
                _net_clear_request_table();
        }
 
@@ -336,8 +324,8 @@ EXPORT_API int net_deregister_client(void)
 
 EXPORT_API int net_deregister_client_ext(net_device_t client_type)
 {
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
-               NETWORK_LOG(NETWORK_ERROR, "Application was not registered\n");
+       if (NetworkInfo.ref_count < 1) {
+               NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                return NET_ERR_APP_NOT_REGISTERED;
        }
 
@@ -363,9 +351,8 @@ EXPORT_API int net_deregister_client_ext(net_device_t client_type)
                return NET_ERR_INVALID_PARAM;
        }
 
-       if (g_atomic_int_dec_and_test(&NetworkInfo.ref_count)) {
+       if (__sync_sub_and_fetch(&NetworkInfo.ref_count, 1) < 1) {
                _net_deregister_signal();
-               _net_mutex_destroy();
                _net_clear_request_table();
        }
 
@@ -616,8 +603,8 @@ EXPORT_API int net_is_connected(void)
        net_err_t Error = NET_ERR_NONE;
 
        __NETWORK_FUNC_ENTER__;
-       
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -659,7 +646,7 @@ EXPORT_API int net_get_network_status(net_device_t device_type, net_cm_network_s
 
        __NETWORK_FUNC_ENTER__;
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -682,7 +669,7 @@ EXPORT_API int net_get_technology_properties(net_device_t tech_type, net_tech_in
 
        __NETWORK_FUNC_ENTER__;
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -704,7 +691,7 @@ EXPORT_API int net_get_statistics(net_device_t device_type, net_statistics_type_
        net_err_t Error = NET_ERR_NONE;
 
        if ((Error = _net_dbus_get_statistics(device_type, statistics_type, size)) != NET_ERR_NONE )
-               NETWORK_LOG(NETWORK_ERROR, "Failed to get statistics. error: [%s]\n",
+               NETWORK_LOG(NETWORK_ERROR, "Failed to get statistics. error: %s\n",
                                _net_print_error(Error));
 
        return Error;
@@ -715,7 +702,7 @@ EXPORT_API int net_set_statistics(net_device_t device_type, net_statistics_type_
        net_err_t Error = NET_ERR_NONE;
 
        if ((Error = _net_dbus_set_statistics(device_type, statistics_type)) != NET_ERR_NONE )
-               NETWORK_LOG(NETWORK_ERROR, "Failed to set statistics. error: [%s]\n",
+               NETWORK_LOG(NETWORK_ERROR, "Failed to set statistics. error: %s\n",
                                _net_print_error(Error));
 
        return Error;
@@ -791,7 +778,7 @@ EXPORT_API int net_open_connection_with_profile(const char *profile_name)
                return NET_ERR_INVALID_PARAM;
        }
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -857,7 +844,7 @@ EXPORT_API int net_open_connection_with_preference(net_service_type_t service_ty
                return NET_ERR_INVALID_PARAM;
        }
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -927,7 +914,7 @@ EXPORT_API int net_open_connection_with_preference_ext(net_service_type_t servic
                return NET_ERR_INVALID_PARAM;
        }
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -1002,7 +989,7 @@ EXPORT_API int net_close_connection(const char *profile_name)
                return NET_ERR_INVALID_PARAM;
        }
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
index 7dc351a917f294d290343a85bc76cc8ea526298a..dec0e6e99fe1a3881a2e07548604a62cd2336cbc 100644 (file)
@@ -17,7 +17,6 @@
  *
  */
 
-#include <vconf.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
 
@@ -32,8 +31,8 @@
 /*****************************************************************************
  *     Extern Variables
  *****************************************************************************/
-extern network_info_t NetworkInfo;
-extern network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
+extern __thread network_info_t NetworkInfo;
+extern __thread network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
 
 static int __net_error_string_to_enum(const char* error)
 {
index 2f2865732211f12416243fdc18cc3017585a2fba..32617d971bf6380ca645aa2bcfe00800975c81f9 100644 (file)
 #include "network-internal.h"
 #include "network-dbus-request.h"
 
-struct networkinfo_mutex_data {
-       pthread_mutex_t callback_mutex;
-       pthread_mutex_t wifi_state_mutex;
-};
-
 struct gdbus_connection_data {
        GDBusConnection *connection;
        int conn_ref_count;
@@ -37,16 +32,14 @@ struct gdbus_connection_data {
 /*****************************************************************************
  *     Extern Global Variables
  *****************************************************************************/
-extern network_info_t NetworkInfo;
+extern __thread network_info_t NetworkInfo;
 
 /*****************************************************************************
  *     Global Variables
  *****************************************************************************/
-network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX] = {{0,},};
+__thread network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX] = { { 0, }, };
 
-static struct networkinfo_mutex_data networkinfo_mutex =
-                                                       { { { 0, }, }, { { 0, }, } };
-static struct gdbus_connection_data gdbus_conn = { NULL, };
+static __thread struct gdbus_connection_data gdbus_conn = { NULL, 0, NULL, NULL };
 
 static char *__convert_eap_type_to_string(gchar eap_type)
 {
@@ -416,40 +409,8 @@ int _net_open_connection_with_wifi_info(const net_wifi_connection_info_t* wifi_i
        return Error;
 }
 
-int _net_mutex_init(void)
-{
-       __NETWORK_FUNC_ENTER__;
-
-       if (pthread_mutex_init(&networkinfo_mutex.callback_mutex, NULL) != 0) {
-               NETWORK_LOG(NETWORK_ERROR, "Mutex for callback initialization failed!\n");
-               __NETWORK_FUNC_EXIT__;
-               return NET_ERR_UNKNOWN;
-       }
-
-       if (pthread_mutex_init(&networkinfo_mutex.wifi_state_mutex, NULL) != 0) {
-               NETWORK_LOG(NETWORK_ERROR, "Mutex for wifi state initialization failed!\n");
-               pthread_mutex_destroy(&networkinfo_mutex.callback_mutex);
-               __NETWORK_FUNC_EXIT__;
-               return NET_ERR_UNKNOWN;
-       }
-
-       __NETWORK_FUNC_EXIT__;
-       return NET_ERR_NONE;
-}
-
-void _net_mutex_destroy(void)
-{
-       __NETWORK_FUNC_ENTER__;
-
-       pthread_mutex_destroy(&networkinfo_mutex.callback_mutex);
-       pthread_mutex_destroy(&networkinfo_mutex.wifi_state_mutex);
-
-       __NETWORK_FUNC_EXIT__;
-}
-
 void _net_client_callback(net_event_info_t *event_data)
 {
-       pthread_mutex_lock(&networkinfo_mutex.callback_mutex);
        __NETWORK_FUNC_ENTER__;
 
        if (NetworkInfo.ClientEventCb != NULL)
@@ -462,12 +423,10 @@ void _net_client_callback(net_event_info_t *event_data)
                NetworkInfo.ClientEventCb_wifi(event_data, NetworkInfo.user_data_wifi);
 
        __NETWORK_FUNC_EXIT__;
-       pthread_mutex_unlock(&networkinfo_mutex.callback_mutex);
 }
 
 net_wifi_state_t _net_get_wifi_state(void)
 {
-       pthread_mutex_lock(&networkinfo_mutex.wifi_state_mutex);
        __NETWORK_FUNC_ENTER__;
 
        net_err_t Error = NET_ERR_NONE;
@@ -491,7 +450,6 @@ net_wifi_state_t _net_get_wifi_state(void)
 
 state_done:
        __NETWORK_FUNC_EXIT__;
-       pthread_mutex_unlock(&networkinfo_mutex.wifi_state_mutex);
        return wifi_state;
 }
 
@@ -509,7 +467,7 @@ void _net_clear_request_table(void)
 
 gboolean _net_dbus_is_pending_call_used(void)
 {
-       if (g_atomic_int_get(&gdbus_conn.conn_ref_count) > 0)
+       if (gdbus_conn.conn_ref_count > 0)
                return TRUE;
 
        return FALSE;
@@ -518,16 +476,18 @@ gboolean _net_dbus_is_pending_call_used(void)
 void _net_dbus_pending_call_ref(void)
 {
        g_object_ref(gdbus_conn.connection);
-       g_atomic_int_inc(&gdbus_conn.conn_ref_count);
+
+       __sync_fetch_and_add(&gdbus_conn.conn_ref_count, 1);
 }
 
 void _net_dbus_pending_call_unref(void)
 {
-       if (g_atomic_int_get(&gdbus_conn.conn_ref_count) < 1)
+       if (gdbus_conn.conn_ref_count < 1)
                return;
 
        g_object_unref(gdbus_conn.connection);
-       if (g_atomic_int_dec_and_test(&gdbus_conn.conn_ref_count) == TRUE &&
+
+       if (__sync_sub_and_fetch(&gdbus_conn.conn_ref_count, 1) < 1 &&
                        gdbus_conn.handle_libnetwork != NULL) {
                NETWORK_LOG(NETWORK_ERROR, "A handle of libnetwork is not NULL\n");
 
@@ -582,8 +542,6 @@ int _net_dbus_create_gdbus_call(void)
 
 int _net_dbus_close_gdbus_call(void)
 {
-       int refcount = 0;
-
        g_cancellable_cancel(gdbus_conn.cancellable);
        g_object_unref(gdbus_conn.cancellable);
        gdbus_conn.cancellable = NULL;
@@ -593,15 +551,15 @@ int _net_dbus_close_gdbus_call(void)
                return NET_ERR_UNKNOWN;
        }
 
-       refcount = g_atomic_int_get(&gdbus_conn.conn_ref_count);
-       if (refcount < 1) {
+       if (gdbus_conn.conn_ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "There is no pending call\n");
 
                g_object_unref(gdbus_conn.connection);
                gdbus_conn.connection = NULL;
        } else {
                NETWORK_LOG(NETWORK_ERROR,
-                               "There are %d pending calls, waiting to be cleared\n", refcount);
+                               "There are %d pending calls, waiting to be cleared\n",
+                               gdbus_conn.conn_ref_count);
 
                if (gdbus_conn.handle_libnetwork != NULL)
                        NETWORK_LOG(NETWORK_ERROR, "A handle of libnetwork is not NULL\n");
index a914d1418f966bee03b0b5f459c8bee04789689a..1c1818dd0f05833b4c16c39b132fe9fa4bb71ca1 100644 (file)
 #include "network-internal.h"
 #include "network-dbus-request.h"
 
-/*****************************************************************************
- *     Macros and Typedefs
- *****************************************************************************/
-
 /*****************************************************************************
  *     Local Functions Declaration
  *****************************************************************************/
@@ -58,18 +54,10 @@ static int __net_set_default_cellular_service_profile_sync(const char* ProfileNa
 static int __net_set_default_cellular_service_profile_async(const char* ProfileName);
 
 /*****************************************************************************
- *     Global Functions
- *****************************************************************************/
-
-/*****************************************************************************
- *     Extern Variables
- *****************************************************************************/
-extern network_info_t NetworkInfo;
-extern network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
-
-/*****************************************************************************
- *     Global Variables
+ * Extern Variables
  *****************************************************************************/
+extern __thread network_info_t NetworkInfo;
+extern __thread network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
 
 /*****************************************************************************
  *     Local Functions Definition
@@ -2020,10 +2008,10 @@ int _net_get_default_profile_info(net_profile_info_t *profile_info)
 EXPORT_API int net_add_profile(net_service_type_t network_type, net_profile_info_t *prof_info)
 {
        net_err_t Error = NET_ERR_NONE;
-       
+
        __NETWORK_FUNC_ENTER__;
-       
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -2044,7 +2032,7 @@ EXPORT_API int net_add_profile(net_service_type_t network_type, net_profile_info
                return Error;
        }
 
-       __NETWORK_FUNC_EXIT__;  
+       __NETWORK_FUNC_EXIT__;
        return Error;
 }
 
@@ -2056,8 +2044,8 @@ EXPORT_API int net_delete_profile(const char* profile_name)
        net_profile_name_t pdp_prof_name;
        net_profile_name_t wifi_prof_name;
        net_profile_info_t prof_info;
-       
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -2126,10 +2114,10 @@ EXPORT_API int net_delete_profile(const char* profile_name)
 EXPORT_API int net_get_profile_info(const char *profile_name, net_profile_info_t *prof_info)
 {
        __NETWORK_FUNC_ENTER__;
-       
+
        net_err_t Error = NET_ERR_NONE;
-       
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -2160,7 +2148,7 @@ EXPORT_API int net_modify_profile(const char* profile_name, net_profile_info_t*
        net_err_t Error = NET_ERR_NONE;
        net_profile_info_t exProfInfo;
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -2215,12 +2203,12 @@ EXPORT_API int net_get_profile_list(net_device_t device_type, net_profile_info_t
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_INVALID_PARAM;
        }
-       
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
-       }       
+       }
 
        if (device_type != NET_DEVICE_CELLULAR &&
            device_type != NET_DEVICE_WIFI &&
@@ -2231,32 +2219,32 @@ EXPORT_API int net_get_profile_list(net_device_t device_type, net_profile_info_t
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_NOT_SUPPORTED;
        }
-       
+
        Error = _net_get_profile_list(device_type, &profile_info, &profile_count);
 
        if (Error != NET_ERR_NONE) {
                NETWORK_LOG(NETWORK_ERROR,
                                "Failed to get service(profile) list. Error [%s]\n",
                                _net_print_error(Error));
-               
+
                NET_MEMFREE(profile_info);
-               
+
                __NETWORK_FUNC_EXIT__;
                return Error;
        } else {
                *count = profile_count;
                *profile_list = profile_info;
        }
-       
-       __NETWORK_FUNC_EXIT__;  
-       return NET_ERR_NONE;    
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
 }
 
 EXPORT_API int net_set_default_cellular_service_profile(const char *profile_name)
 {
        net_err_t Error = NET_ERR_NONE;
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -2284,8 +2272,8 @@ EXPORT_API int net_set_default_cellular_service_profile_async(const char *profil
 {
        net_err_t Error = NET_ERR_NONE;
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
-               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+       if (NetworkInfo.ref_count < 1) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
        }
@@ -2296,7 +2284,7 @@ EXPORT_API int net_set_default_cellular_service_profile_async(const char *profil
                return NET_ERR_INVALID_PARAM;
        }
 
-       if(request_table[NETWORK_REQUEST_TYPE_SET_DEFAULT].flag == TRUE) {
+       if (request_table[NETWORK_REQUEST_TYPE_SET_DEFAULT].flag == TRUE) {
                NETWORK_LOG(NETWORK_ERROR, "Error!! Request already in progress\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_IN_PROGRESS;
index 1a232aeb907a0dd76555d363744cdb5be2c23de6..ec137deff70d1aa74266174d2a539dfd4962df22 100644 (file)
  *
  */
 
-#include <vconf.h>
-
 #include "network-internal.h"
 #include "network-dbus-request.h"
 #include "network-signal-handler.h"
 
-extern network_info_t NetworkInfo;
-extern network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
+extern __thread network_info_t NetworkInfo;
+extern __thread network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
 
-static net_state_type_t service_state_table[NET_DEVICE_MAX] = {NET_STATE_TYPE_UNKNOWN,};
-static int net_service_error = NET_ERR_NONE;
-static guint gdbus_conn_subscribe_id_connman_svc = 0;
-static guint gdbus_conn_subscribe_id_supplicant = 0;
-static guint gdbus_conn_subscribe_id_netconfig = 0;
+static __thread net_state_type_t service_state_table[NET_DEVICE_MAX] =
+                                               { NET_STATE_TYPE_UNKNOWN, };
+static __thread int net_service_error = NET_ERR_NONE;
+static __thread guint gdbus_conn_subscribe_id_connman_svc = 0;
+static __thread guint gdbus_conn_subscribe_id_supplicant = 0;
+static __thread guint gdbus_conn_subscribe_id_netconfig = 0;
 
 static int __net_handle_wifi_power_rsp(gboolean value)
 {
index ff42111ffdb20f3c216e8b6ada192d59742e4859..74a50529fc4aaa5018657f654c2bb6292a54e3b2 100644 (file)
 #include "network-dbus-request.h"
 #include "network-signal-handler.h"
 
-/*****************************************************************************
- *     Macros and Typedefs
- *****************************************************************************/
-
-/*****************************************************************************
- *     Local Functions Declaration
- *****************************************************************************/
-static net_wifi_state_t __net_get_wifi_service_state();
-
-/*****************************************************************************
- *     Global Functions
- *****************************************************************************/
-
 /*****************************************************************************
  *     Extern Variables
  *****************************************************************************/
-extern network_info_t NetworkInfo;
-extern network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
-
-/*****************************************************************************
- *     Global Variables
- *****************************************************************************/
+extern __thread network_info_t NetworkInfo;
+extern __thread network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
 
 /*****************************************************************************
  *     Local Functions Definition
@@ -145,7 +128,7 @@ EXPORT_API int net_specific_scan_wifi(const char *ssid)
                return NET_ERR_INVALID_PARAM;
        }
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -197,7 +180,7 @@ EXPORT_API int net_open_connection_with_wifi_info(const net_wifi_connection_info
                return NET_ERR_INVALID_PARAM;
        }
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -247,7 +230,7 @@ EXPORT_API int net_wifi_power_on(void)
        net_err_t Error = NET_ERR_NONE;
        int hotspot_state = 0;
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -305,7 +288,7 @@ EXPORT_API int net_wifi_power_off(void)
 
        net_err_t Error = NET_ERR_NONE;
 
-       if(g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -360,7 +343,7 @@ EXPORT_API int net_scan_wifi(void)
 
        net_err_t Error = NET_ERR_NONE;
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -421,7 +404,7 @@ EXPORT_API int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_t
                return NET_ERR_INVALID_PARAM;
        }
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -493,7 +476,7 @@ EXPORT_API int net_get_wifi_state(net_wifi_state_t *current_state, net_profile_n
 
        net_wifi_state_t wifi_state;
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
@@ -529,9 +512,8 @@ EXPORT_API int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_t
 
        net_err_t Error = NET_ERR_NONE;
 
-       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+       if (NetworkInfo.ref_count < 1) {
                NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
-
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_APP_NOT_REGISTERED;
        }