From: Seonah Moon Date: Tue, 30 May 2017 05:18:00 +0000 (+0900) Subject: Added softap handle list to avoid timing issue X-Git-Tag: submit/tizen/20170607.064606^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=96dce7f4fc860c3f8b5ea9d1e1097fd53a745f1b;p=platform%2Fcore%2Fapi%2Fsoftap.git Added softap handle list to avoid timing issue Change-Id: If63b2fae6ee981b78c24d9071d8d16896320a2fe Signed-off-by: Seonah Moon --- diff --git a/include/softap_private.h b/include/softap_private.h index 8372646..7c7e5ec 100644 --- a/include/softap_private.h +++ b/include/softap_private.h @@ -252,6 +252,9 @@ typedef struct { bool visibility; } _softap_settings_t; +void _softap_add_handle(softap_h handle); +void _softap_remove_handle(softap_h handle); +bool _softap_check_handle(softap_h handle); #ifdef __cplusplus } #endif diff --git a/src/softap.c b/src/softap.c index b44ca2d..c4bccce 100755 --- a/src/softap.c +++ b/src/softap.c @@ -492,6 +492,11 @@ static void __enabled_cfm_cb(GObject *source_object, GAsyncResult *res, softap_enabled_cb ecb = sa->enabled_cb; void *data = sa->enabled_user_data; + if (!_softap_check_handle((softap_h)user_data)) { + DBG("Softap handle is already destroyed"); + return; + } + g_var = g_dbus_proxy_call_finish(sa->client_bus_proxy, res, &g_error); if (g_error) { ERR("DBus error [%s]", g_error->message); @@ -542,6 +547,11 @@ static void __disabled_cfm_cb(GObject *source_object, GAsyncResult *res, softap_disabled_cb dcb = sa->disabled_cb; void *data = sa->disabled_user_data; + if (!_softap_check_handle((softap_h) sa)) { + DBG("Softap handle is already destroyed"); + return; + } + g_var = g_dbus_proxy_call_finish(sa->client_bus_proxy, res, &g_error); if (g_error) { ERR("DBus error [%s]", g_error->message); @@ -773,13 +783,11 @@ API int softap_create(softap_h *softap) __connect_signals((softap_h)sa); - DBG("[DBG] create sig.id for softap on (%d)", sigs[E_SIGNAL_SOFTAP_ON].sig_id); - *softap = (softap_h) sa; - DBG("SoftAP Handle[0x%X] SSID[%s] Passphrase[%s] Security[%d] Visibilit[%d]", - sa, sa->ssid, sa->passphrase, sa->sec_type, sa->visibility); - DBG("-"); + _softap_add_handle(sa); + + DBG("-"); return SOFTAP_ERROR_NONE; } @@ -802,6 +810,9 @@ API int softap_destroy(softap_h softap) g_object_unref(sa->client_bus_proxy); g_object_unref(sa->client_bus); memset(sa, 0x00, sizeof(__softap_h)); + + _softap_remove_handle(sa); + free(sa); sa = NULL; diff --git a/src/softap_private.c b/src/softap_private.c index 985d3ed..4489255 100755 --- a/src/softap_private.c +++ b/src/softap_private.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -22,6 +23,7 @@ #define WIFI_FEATURE "http://tizen.org/feature/network.wifi" static __thread bool is_feature_checked = 0; static __thread bool feature_supported = 0; +static __thread GSList *softap_handle_list = NULL; int _softap_check_feature_supported(const char *key) { @@ -40,3 +42,21 @@ int _softap_check_feature_supported(const char *key) return SOFTAP_ERROR_NONE; } + +void _softap_add_handle(softap_h handle) +{ + softap_handle_list = g_slist_append(softap_handle_list, handle); +} + +void _softap_remove_handle(softap_h handle) +{ + softap_handle_list = g_slist_remove(softap_handle_list, handle); +} + +bool _softap_check_handle(softap_h handle) +{ + if (g_slist_find(softap_handle_list, handle) != NULL) + return true; + else + return false; +}