public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 06/10] telephony-ofono: fix not canceling pending calls on exit
Date: Wed,  5 Jan 2011 17:59:43 +0200	[thread overview]
Message-ID: <1294243187-1849-7-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1294243187-1849-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

---
 audio/telephony-ofono.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/audio/telephony-ofono.c b/audio/telephony-ofono.c
index e1b6422..c554305 100644
--- a/audio/telephony-ofono.c
+++ b/audio/telephony-ofono.c
@@ -56,6 +56,7 @@ static DBusConnection *connection = NULL;
 static char *modem_obj_path = NULL;
 static char *last_dialed_number = NULL;
 static GSList *calls = NULL;
+static GSList *pending = NULL;
 
 #define OFONO_BUS_NAME "org.ofono"
 #define OFONO_PATH "/"
@@ -226,7 +227,7 @@ static int send_method_call(const char *dest, const char *path,
 	}
 
 	dbus_pending_call_set_notify(call, cb, user_data, NULL);
-	dbus_pending_call_unref(call);
+	pending = g_slist_prepend(pending, call);
 	dbus_message_unref(msg);
 
 	return 0;
@@ -610,6 +611,12 @@ static struct voice_call *call_new(const char *path, DBusMessageIter *properties
 	return vc;
 }
 
+static void remove_pending(DBusPendingCall *call)
+{
+	pending = g_slist_remove(pending, call);
+	dbus_pending_call_unref(call);
+}
+
 static void call_added(const char *path, DBusMessageIter *properties)
 {
 	struct voice_call *vc;
@@ -668,6 +675,7 @@ static void get_calls_reply(DBusPendingCall *call, void *user_data)
 
 done:
 	dbus_message_unref(reply);
+	remove_pending(call);
 }
 
 static void handle_network_property(const char *property, DBusMessageIter *variant)
@@ -783,6 +791,7 @@ static void get_properties_reply(DBusPendingCall *call, void *user_data)
 
 done:
 	dbus_message_unref(reply);
+	remove_pending(call);
 }
 
 static void modem_added(const char *path)
@@ -842,6 +851,7 @@ static void get_modems_reply(DBusPendingCall *call, void *user_data)
 
 done:
 	dbus_message_unref(reply);
+	remove_pending(call);
 }
 
 static gboolean handle_network_property_changed(DBusConnection *conn,
@@ -1052,6 +1062,7 @@ static void hal_battery_level_reply(DBusPendingCall *call, void *user_data)
 	}
 done:
 	dbus_message_unref(reply);
+	remove_pending(call);
 }
 
 static void hal_get_integer(const char *path, const char *key, void *user_data)
@@ -1170,6 +1181,7 @@ static void hal_find_device_reply(DBusPendingCall *call, void *user_data)
 	hal_get_integer(path, "battery.charge_level.design", &battchg_design);
 done:
 	dbus_message_unref(reply);
+	remove_pending(call);
 }
 
 int telephony_init(void)
@@ -1252,6 +1264,11 @@ void telephony_exit(void)
 	g_dbus_remove_watch(connection, call_removed_watch);
 	g_dbus_remove_watch(connection, device_watch);
 
+	g_slist_foreach(pending, (GFunc) dbus_pending_call_cancel, NULL);
+	g_slist_foreach(pending, (GFunc) dbus_pending_call_unref, NULL);
+	g_slist_free(pending);
+	pending = NULL;
+
 	dbus_connection_unref(connection);
 	connection = NULL;
 
-- 
1.7.1


  parent reply	other threads:[~2011-01-05 15:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-05 15:59 [PATCH 00/10] Update telephony-ofono driver Luiz Augusto von Dentz
2011-01-05 15:59 ` [PATCH 01/10] telephony-ofono: notify alerting calls when headset connects Luiz Augusto von Dentz
2011-01-05 15:59 ` [PATCH 02/10] telephony-ofono: fix not being able to answer alerting/waiting calls Luiz Augusto von Dentz
2011-01-05 15:59 ` [PATCH 03/10] telephony-ofono: fix not setting originating when status property changes Luiz Augusto von Dentz
2011-01-05 15:59 ` [PATCH 04/10] telephony-ofono: make use of GetModems method Luiz Augusto von Dentz
2011-01-05 15:59 ` [PATCH 05/10] telephony-ofono: make use of GetCalls method Luiz Augusto von Dentz
2011-01-05 15:59 ` Luiz Augusto von Dentz [this message]
2011-01-05 15:59 ` [PATCH 07/10] telephony-ofono: simplify watches handling logic Luiz Augusto von Dentz
2011-01-05 15:59 ` [PATCH 08/10] telephony-ofono: handle ofono appearing/disappearing from bus Luiz Augusto von Dentz
2011-01-05 15:59 ` [PATCH 09/10] telephony-ofono: add handling for Modem.Interfaces property Luiz Augusto von Dentz
2011-01-05 15:59 ` [PATCH 10/10] telephony-ofono: fix not updating indicators when a call is removed Luiz Augusto von Dentz
2011-01-06 22:39 ` [PATCH 00/10] Update telephony-ofono driver Johan Hedberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1294243187-1849-7-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox