Added softap handle list to avoid timing issue 71/131571/2 accepted/tizen/unified/20170608.072303 submit/tizen/20170607.064606
authorSeonah Moon <seonah1.moon@samsung.com>
Tue, 30 May 2017 05:18:00 +0000 (14:18 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Tue, 30 May 2017 08:52:18 +0000 (17:52 +0900)
Change-Id: If63b2fae6ee981b78c24d9071d8d16896320a2fe
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
include/softap_private.h
src/softap.c
src/softap_private.c

index 8372646d1438bac774d5d60f07955434ea563956..7c7e5ecaa54b928205cd9892ba4f652fff217ce0 100644 (file)
@@ -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
index b44ca2d9cda71471687810301cdae3fb680ec360..c4bccce17fede26a9df43084fcdb0a9b9a9f09d4 100755 (executable)
@@ -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;
 
index 985d3ed7079ce1d7d2de179bab5606827e661cad..44892559f508d5970bafaad9f000e3f5f0bd5507 100755 (executable)
@@ -14,6 +14,7 @@
 * limitations under the License.
 */
 
+#include <glib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <system_info.h>
@@ -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;
+}