Open Source Telephony
 help / color / mirror / Atom feed
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis <frederic.danis@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 1/4] bluetooth: only use bluetooth_refcount in bluetooth_ref/bluetooth_unref
Date: Thu, 27 Jan 2011 16:05:37 +0100	[thread overview]
Message-ID: <1296140740-11486-2-git-send-email-frederic.danis@linux.intel.com> (raw)
In-Reply-To: <1296140740-11486-1-git-send-email-frederic.danis@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1298 bytes --]

---
 plugins/bluetooth.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 93dd7a1..e59bd31 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -505,7 +505,7 @@ static guint adapter_added_watch;
 static guint adapter_removed_watch;
 static guint property_watch;
 
-static void bluetooth_ref(void)
+static int bluetooth_ref(void)
 {
 	if (bluetooth_refcount > 0)
 		goto increment;
@@ -544,13 +544,15 @@ static void bluetooth_ref(void)
 increment:
 	g_atomic_int_inc(&bluetooth_refcount);
 
-	return;
+	return 0;
 
 remove:
 	g_dbus_remove_watch(connection, bluetooth_watch);
 	g_dbus_remove_watch(connection, adapter_added_watch);
 	g_dbus_remove_watch(connection, adapter_removed_watch);
 	g_dbus_remove_watch(connection, property_watch);
+
+	return -EIO;
 }
 
 static void bluetooth_unref(void)
@@ -569,10 +571,12 @@ static void bluetooth_unref(void)
 
 int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile)
 {
-	bluetooth_ref();
+	int err;
+
+	err = bluetooth_ref();
 
-	if (bluetooth_refcount == 0)
-		return -EIO;
+	if (err != 0)
+		return err;
 
 	g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
 
-- 
1.7.1


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

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-27 15:05 [PATCH v2 0/4] bluetooth: Add bluetooth server support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-01-27 15:05 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis [this message]
2011-01-27 15:12   ` [PATCH 1/4] bluetooth: only use bluetooth_refcount in bluetooth_ref/bluetooth_unref Marcel Holtmann
2011-01-27 15:25     ` Frederic Danis
2011-01-27 16:17       ` Gustavo F. Padovan
2011-01-27 16:18         ` Marcel Holtmann
2011-01-27 15:05 ` [PATCH 2/4] bluetooth: use GSList instead of GHashTable to store adapter path/address =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-01-27 15:13   ` Marcel Holtmann
2011-01-27 15:22     ` Frederic Danis
2011-01-27 15:24       ` Marcel Holtmann
2011-01-27 15:35         ` Frederic Danis
2011-01-27 16:19           ` Gustavo F. Padovan
2011-01-27 15:05 ` [PATCH 3/4] bluetooth: Add bluetooth server support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-01-27 16:26   ` Gustavo F. Padovan
2011-01-27 16:32     ` Frederic Danis
2011-01-27 15:05 ` [PATCH 4/4] bluetooth: add Bluetooth service authorization support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis

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=1296140740-11486-2-git-send-email-frederic.danis@linux.intel.com \
    --to=frederic.danis@linux.intel.com \
    --cc=ofono@ofono.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