Fix the crash in Web bluetooth TC
authorDoHyun Pyun <dh79.pyun@samsung.com>
Fri, 7 Sep 2012 06:53:58 +0000 (15:53 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Fri, 7 Sep 2012 06:53:58 +0000 (15:53 +0900)
[Issue] Crash in Web bluetooth TC

[Cause] Did not remove the timer before existing thread

[Solution] Remove the timer in unregister callback

Change-Id: I742a28f901334f0d69fbd6c47f80c82d8647ad38

bluetooth-telephony/bluetooth-telephony-api.c
bluetooth-telephony/bluetooth-telephony-api.h
debian/changelog
lib/bluetooth-api-common.c
lib/bluetooth-api-common.h
lib/bluetooth-gap-api.c
packaging/bluetooth-frwk.spec

index e4f0354..5258b5b 100644 (file)
@@ -1076,6 +1076,7 @@ BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb,
 
        if (telephony_dbus_info.manager_proxy == NULL) {
                DBG("Could not create a manager proxy\n");
+               __bluetooth_telephony_proxy_deinit();
                dbus_g_connection_unref(telephony_dbus_info.conn);
                telephony_dbus_info.conn = NULL;
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
@@ -1086,6 +1087,7 @@ BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb,
                        DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
 
        if (NULL == telephony_dbus_info.dbus_proxy) {
+               __bluetooth_telephony_proxy_deinit();
                dbus_g_connection_unref(telephony_dbus_info.conn);
                telephony_dbus_info.conn = NULL;
                g_object_unref(telephony_dbus_info.manager_proxy);
@@ -1116,21 +1118,6 @@ BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb,
        telephony_info.cb = cb;
        telephony_info.user_data = user_data;
 
-       /*Check for BT status*/
-       ret = __bluetooth_get_default_adapter_path(telephony_dbus_info.conn,
-                                                               object_path);
-       if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE)
-               return BLUETOOTH_TELEPHONY_ERROR_NOT_ENABLED;
-
-       /*Bluetooth is active, therefore set the flag */
-       is_active = TRUE;
-
-       ret = __bluetooth_telephony_register();
-       if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE) {
-               DBG("__bluetooth_telephony_register failed\n");
-               goto fail;
-       }
-
        dbus_error_init(&dbus_error);
        conn = dbus_g_connection_get_connection(telephony_dbus_info.conn);
        dbus_connection_add_filter(conn, __bluetooth_telephony_event_filter,
@@ -1143,13 +1130,27 @@ BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb,
        if (dbus_error_is_set(&dbus_error)) {
                DBG("Fail to add dbus filter signal\n");
                dbus_error_free(&dbus_error);
-               __bluetooth_telephony_unregister();
                dbus_connection_remove_filter(dbus_g_connection_get_connection(
                                telephony_dbus_info.conn),
                                __bluetooth_telephony_event_filter, NULL);
                goto fail;
        }
 
+       /*Check for BT status*/
+       ret = __bluetooth_get_default_adapter_path(telephony_dbus_info.conn,
+                                                               object_path);
+       if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE)
+               return BLUETOOTH_TELEPHONY_ERROR_NOT_ENABLED;
+
+       /*Bluetooth is active, therefore set the flag */
+       is_active = TRUE;
+
+       ret = __bluetooth_telephony_register();
+       if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE) {
+               DBG("__bluetooth_telephony_register failed\n");
+               goto fail;
+       }
+
        DBG("bluetooth_telephony_init -\n");
        return ret;
 fail:
@@ -1165,8 +1166,6 @@ fail:
                G_CALLBACK(__bluetooth_telephony_name_owner_changed),
                NULL);
 
-       g_object_unref(telephony_dbus_info.dbus_proxy);
-
        /*Remove BT enabled signal*/
        dbus_g_proxy_disconnect_signal(
                telephony_dbus_info.manager_proxy,
@@ -1209,8 +1208,6 @@ BT_EXPORT_API int bluetooth_telephony_deinit(void)
                G_CALLBACK(__bluetooth_telephony_name_owner_changed),
                NULL);
 
-       g_object_unref(telephony_dbus_info.dbus_proxy);
-
        /*Remove BT enabled signal*/
        dbus_g_proxy_disconnect_signal(
                telephony_dbus_info.manager_proxy,
index a674b49..513d4cb 100644 (file)
@@ -329,7 +329,7 @@ gboolean bluetooth_telephony_is_sco_connected(void);
  * @brief      The function bluetooth_telephony_get_headset_volume is called to get
  *     the changed Volume on AG.
  *
- * @param[out] speaker_gain    Speaker gain.
+ * @param[out] speaker_gain            Speaker gain.
  * @return     int     Zero on Success or reason for error if any.
  *
  */
@@ -339,7 +339,7 @@ int bluetooth_telephony_get_headset_volume(unsigned int *speaker_gain);
  * @brief      The function bluetooth_telephony_set_speaker_gain is called to indicate
  *     that the Volume on AG is changed.
  *
- * @param[in]  speaker_gain    Speaker gain.
+ * @param[in]  speaker_gain            Speaker gain.
  * @return     int     Zero on Success or reason for error if any.
  *
  */
index 6da6d2a..224dbe2 100644 (file)
@@ -1,3 +1,11 @@
+bluetooth-frwk (0.1.88) unstable; urgency=low
+
+  * Tagging and upload the package
+  * Git: slp/pkgs/b/bluetooth-frwk
+  * Tag: bluetooth-frwk_0.1.88
+
+ -- DoHyun Pyun <dh79.pyun@samsung.com>  Fri, 07 Sep 2012 15:23:55 +0900
+
 bluetooth-frwk (0.1.87) unstable; urgency=low
 
   * Tagging and upload the package
index c1945b9..3641852 100644 (file)
@@ -653,6 +653,8 @@ gboolean _bt_discovery_finished_cb(gpointer user_data)
 {
        DBG("+");
 
+       bt_info.bt_discovery_res_timer = 0;
+
        if (bluetooth_is_discovering() == FALSE) {
                bt_info.is_discovering = FALSE;
                _bluetooth_internal_discovery_completed_cb();
@@ -686,7 +688,7 @@ static void __bluetooth_internal_adapter_property_changed(DBusGProxy *adapter,
                        dbus_g_proxy_call(adapter, "StopDiscovery", NULL,
                                        G_TYPE_INVALID, G_TYPE_INVALID);
 
-                       g_timeout_add(BT_DISCOVERY_FINISHED_DELAY,
+                       bt_info.bt_discovery_res_timer = g_timeout_add(BT_DISCOVERY_FINISHED_DELAY,
                                      (GSourceFunc)_bt_discovery_finished_cb, NULL);
                } else {
                        if (bt_info.is_discovering == FALSE) {
index 78dc2aa..d549ce4 100644 (file)
@@ -182,6 +182,7 @@ typedef struct {
 
        guint bt_discovery_req_timer;                   /**< g_timeout for checking timeout of
                                                        BT discovery request */
+       guint bt_discovery_res_timer;
        gboolean is_discovery_req;                      /**< application request discovery or not*/
        gboolean is_discovering;                        /**< Currently discovery state */
        gboolean is_discovery_cancel;                   /**< discovery cancel is requested */
index 1d7f93f..ecf5574 100644 (file)
@@ -930,6 +930,11 @@ BT_EXPORT_API int bluetooth_cancel_discovery(void)
                return ret;
        }
 
+       if (bt_internal_info->bt_discovery_req_timer != 0) {
+               g_source_remove(bt_internal_info->bt_discovery_req_timer);
+               bt_internal_info->bt_discovery_req_timer = 0;
+       }
+
        bt_internal_info->is_discovery_cancel = TRUE;
 
        DBG("-");
index b05d361..c7ae5f2 100644 (file)
@@ -1,6 +1,6 @@
 Name:       bluetooth-frwk
 Summary:    Bluetooth framework for BlueZ and Obexd. This package is Bluetooth framework based on BlueZ and Obexd stack.
-Version:    0.1.87
+Version:    0.1.88
 Release:    1
 Group:      TO_BE/FILLED_IN
 License:    TO BE FILLED IN