Linux bluetooth development
 help / color / mirror / Atom feed
* Re: Oops in rfcomm_sock_getsockopt on net-next as of 20131111
From: Marcel Holtmann @ 2013-11-11 11:05 UTC (permalink / raw)
  To: Bjørn Mork; +Cc: linux-bluetooth@vger.kernel.org development, netdev
In-Reply-To: <874n7j6xei.fsf@nemi.mork.no>

Hi Bjorn,

> I got this when I booted my laptop with todays net-next:
> 
> [   16.064546] BUG: unable to handle kernel paging request at 00000c8bfd080975
> [   16.064558] IP: [<ffffffffa07f65b3>] rfcomm_sock_getsockopt+0x62/0x251 [rfcomm]
> [   16.064561] PGD 0 
> [   16.064564] Oops: 0000 [#1] SMP 
> [   16.064637] Modules linked in: rfcomm bnep xt_hl binfmt_misc ip6table_filter ip6_tables x_tables nfsd nfs_acl nfs lockd fscache sunrpc 8021q garp stp llc tun loop fuse iTCO_wdt iTCO_vendor_support snd_hda_codec_conexant arc4 snd_hda_intel snd_hda_codec snd_hwdep snd_pcm_oss snd_mixer_oss iwlmvm mac80211 snd_pcm snd_page_alloc thinkpad_acpi nvram snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq iwlwifi coretemp uvcvideo cdc_mbim cdc_wdm videobuf2_vmalloc videobuf2_memops cdc_ncm kvm_intel videobuf2_core snd_seq_device psmouse usbnet lpc_ich videodev kvm snd_timer evdev serio_raw mfd_core mii cfg80211 i2c_i801 snd soundcore battery ac i915 i2c_algo_bit drm_kms_helper drm i2c_core acpi_cpufreq video wmi processor button btusb bluetooth rfkill ext4 crc16 jbd2 mbcache nbd sg sd_mod crc_t10dif sr_mod cdrom crct10dif_common ahci libahci microcode libata scsi_mod thermal thermal_sys ehci_pci uhci_hcd ehci_hcd e1000e usbcore ptp pps_core usb_common
> [   16.064656] CPU: 1 PID: 3153 Comm: bluetoothd Not tainted 3.12.0+ #136
> [   16.064658] Hardware name: LENOVO 2776LEG/2776LEG, BIOS 6EET55WW (3.15 ) 12/19/2011
> [   16.064660] task: ffff88022e50a440 ti: ffff8800b78b4000 task.ti: ffff8800b78b4000
> [   16.064669] RIP: 0010:[<ffffffffa07f65b3>]  [<ffffffffa07f65b3>] rfcomm_sock_getsockopt+0x62/0x251 [rfcomm]
> [   16.064670] RSP: 0018:ffff8800b78b5ed8  EFLAGS: 00010246
> [   16.064672] RAX: 00000c8bfd080975 RBX: ffff8800b688b140 RCX: 00007fff7ae042f8
> [   16.064674] RDX: 0000000000000003 RSI: 0000000000000012 RDI: ffff8800b688b140
> [   16.064676] RBP: ffff8800b78b5f28 R08: 00007fff7ae042fc R09: 00007fff7ae042f8
> [   16.064678] R10: 00007fff7ae042f8 R11: ffff8800b83ec180 R12: ffff8800b78bc800
> [   16.064680] R13: 00007fff7ae042f8 R14: 0000000000000003 R15: ffff8800b78bc800
> [   16.064682] FS:  00007f020d523740(0000) GS:ffff88023b000000(0000) knlGS:0000000000000000
> [   16.064685] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [   16.064687] CR2: 00000c8bfd080975 CR3: 00000000b78a2000 CR4: 00000000000007e0
> [   16.064688] Stack:
> [   16.064692]  ffff8800b78b5f08 00007fff7ae042fc ffffffff8139b647 00007fff7ae04570
> [   16.064696]  ffff8800b78b5f50 ffff8800b688b140 0000000000000012 0000000000000003
> [   16.064700]  0000000000000011 00007f020e6abce0 ffff8800b78b5f78 ffffffff812b8215
> [   16.064701] Call Trace:
> [   16.064708]  [<ffffffff8139b647>] ? sysret_check+0x1b/0x56
> [   16.064714]  [<ffffffff812b8215>] SyS_getsockopt+0x79/0x99
> [   16.064718]  [<ffffffff8139b622>] system_call_fastpath+0x16/0x1b
> [   16.064756] Code: a0 31 c0 48 c7 c7 08 e0 7f a0 e8 35 45 9f e0 41 83 ff 12 0f 85 1e 01 00 00 4c 8b 7b 20 f6 05 a6 7a 00 00 04 49 8b 87 18 05 00 00 <4c> 8b 20 74 18 4c 89 fa 48 c7 c6 8f b9 7f a0 31 c0 48 c7 c7 30 
> [   16.064763] RIP  [<ffffffffa07f65b3>] rfcomm_sock_getsockopt+0x62/0x251 [rfcomm]
> [   16.064764]  RSP <ffff8800b78b5ed8>
> [   16.064766] CR2: 00000c8bfd080975
> [   16.064769] ---[ end trace f71c8d4720ff0e6f ]---
> 
> 
> I am using standard Debian startup scripts AFAIK, doing:
> 
>  /usr/bin/rfcomm -f /etc/bluetooth/rfcomm.conf bind all
> 
> where my rfcomm.conf is completely empty except for comments.  The
> reported userspace version is
> 
> RFCOMM configuration utility ver 4.99
> 
> Let me know if there is any other information you need to debug this
> further.

known issue. Check 0be087f56118b67479b6e1a542d1dcf54fa83615 from bluetooth-next tree. We just have not pushed that through wireless-next and net-next yet.

Regards

Marcel


^ permalink raw reply

* Oops in rfcomm_sock_getsockopt on net-next as of 20131111
From: Bjørn Mork @ 2013-11-11 10:33 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: netdev

Hello,

I got this when I booted my laptop with todays net-next:

[   16.064546] BUG: unable to handle kernel paging request at 00000c8bfd080975
[   16.064558] IP: [<ffffffffa07f65b3>] rfcomm_sock_getsockopt+0x62/0x251 [rfcomm]
[   16.064561] PGD 0 
[   16.064564] Oops: 0000 [#1] SMP 
[   16.064637] Modules linked in: rfcomm bnep xt_hl binfmt_misc ip6table_filter ip6_tables x_tables nfsd nfs_acl nfs lockd fscache sunrpc 8021q garp stp llc tun loop fuse iTCO_wdt iTCO_vendor_support snd_hda_codec_conexant arc4 snd_hda_intel snd_hda_codec snd_hwdep snd_pcm_oss snd_mixer_oss iwlmvm mac80211 snd_pcm snd_page_alloc thinkpad_acpi nvram snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq iwlwifi coretemp uvcvideo cdc_mbim cdc_wdm videobuf2_vmalloc videobuf2_memops cdc_ncm kvm_intel videobuf2_core snd_seq_device psmouse usbnet lpc_ich videodev kvm snd_timer evdev serio_raw mfd_core mii cfg80211 i2c_i801 snd soundcore battery ac i915 i2c_algo_bit drm_kms_helper drm i2c_core acpi_cpufreq video wmi processor button btusb bluetooth rfkill ext4 crc16 jbd2 mbcache nbd sg sd_mod crc_t10dif sr_mod cdrom crct10dif_common ahci libahci microcode libata scsi_mod thermal thermal_sys ehci_pci uhci_hcd ehci_hcd e1000e usbcore ptp pps_core usb_common
[   16.064656] CPU: 1 PID: 3153 Comm: bluetoothd Not tainted 3.12.0+ #136
[   16.064658] Hardware name: LENOVO 2776LEG/2776LEG, BIOS 6EET55WW (3.15 ) 12/19/2011
[   16.064660] task: ffff88022e50a440 ti: ffff8800b78b4000 task.ti: ffff8800b78b4000
[   16.064669] RIP: 0010:[<ffffffffa07f65b3>]  [<ffffffffa07f65b3>] rfcomm_sock_getsockopt+0x62/0x251 [rfcomm]
[   16.064670] RSP: 0018:ffff8800b78b5ed8  EFLAGS: 00010246
[   16.064672] RAX: 00000c8bfd080975 RBX: ffff8800b688b140 RCX: 00007fff7ae042f8
[   16.064674] RDX: 0000000000000003 RSI: 0000000000000012 RDI: ffff8800b688b140
[   16.064676] RBP: ffff8800b78b5f28 R08: 00007fff7ae042fc R09: 00007fff7ae042f8
[   16.064678] R10: 00007fff7ae042f8 R11: ffff8800b83ec180 R12: ffff8800b78bc800
[   16.064680] R13: 00007fff7ae042f8 R14: 0000000000000003 R15: ffff8800b78bc800
[   16.064682] FS:  00007f020d523740(0000) GS:ffff88023b000000(0000) knlGS:0000000000000000
[   16.064685] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   16.064687] CR2: 00000c8bfd080975 CR3: 00000000b78a2000 CR4: 00000000000007e0
[   16.064688] Stack:
[   16.064692]  ffff8800b78b5f08 00007fff7ae042fc ffffffff8139b647 00007fff7ae04570
[   16.064696]  ffff8800b78b5f50 ffff8800b688b140 0000000000000012 0000000000000003
[   16.064700]  0000000000000011 00007f020e6abce0 ffff8800b78b5f78 ffffffff812b8215
[   16.064701] Call Trace:
[   16.064708]  [<ffffffff8139b647>] ? sysret_check+0x1b/0x56
[   16.064714]  [<ffffffff812b8215>] SyS_getsockopt+0x79/0x99
[   16.064718]  [<ffffffff8139b622>] system_call_fastpath+0x16/0x1b
[   16.064756] Code: a0 31 c0 48 c7 c7 08 e0 7f a0 e8 35 45 9f e0 41 83 ff 12 0f 85 1e 01 00 00 4c 8b 7b 20 f6 05 a6 7a 00 00 04 49 8b 87 18 05 00 00 <4c> 8b 20 74 18 4c 89 fa 48 c7 c6 8f b9 7f a0 31 c0 48 c7 c7 30 
[   16.064763] RIP  [<ffffffffa07f65b3>] rfcomm_sock_getsockopt+0x62/0x251 [rfcomm]
[   16.064764]  RSP <ffff8800b78b5ed8>
[   16.064766] CR2: 00000c8bfd080975
[   16.064769] ---[ end trace f71c8d4720ff0e6f ]---


I am using standard Debian startup scripts AFAIK, doing:

  /usr/bin/rfcomm -f /etc/bluetooth/rfcomm.conf bind all

where my rfcomm.conf is completely empty except for comments.  The
reported userspace version is

 RFCOMM configuration utility ver 4.99

Let me know if there is any other information you need to debug this
further.



Bjørn

^ permalink raw reply

* Re: [PATCH 1/3] gdbus: Don't try to remove removed sources
From: Luiz Augusto von Dentz @ 2013-11-11  9:32 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1384016658.3880.39.camel@nuvo>

Hi Bastien,

On Sat, Nov 9, 2013 at 7:04 PM, Bastien Nocera <hadess@hadess.net> wrote:
> On Sat, 2013-11-09 at 18:02 +0100, Bastien Nocera wrote:
>> When we return FALSE from idle handlers, the source is removed.
>> This will be causing warnings in glib 2.40.
>>
>> See https://bugzilla.gnome.org/show_bug.cgi?id=710724
>
> Note that there's plenty of other places where this should be fixed.
> I'll leave those up to somebody who doesn't get RSI ;)

Btw, did you really got a problem or was just by looking at the code?
process_changes always call remove_pending so perhaps the problem was
just in generic_unregister, so the change to process_changes was not
really necessary.

-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH 3/3] obex: Use XDG_RUNTIME_DIR as a default root
From: Luiz Augusto von Dentz @ 2013-11-11  9:00 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1384091198.4593.6.camel@nuvo>

Hi Bastien,

On Sun, Nov 10, 2013 at 3:46 PM, Bastien Nocera <hadess@hadess.net> wrote:
> On Sat, 2013-11-09 at 18:03 +0100, Bastien Nocera wrote:
>> It's per-user, so we won't try to overwrite somebody else's
>> files in /tmp when that happens.
>
> There might be another useful directory instead. We could use
> g_get_user_cache_dir() instead of the run-time dir. This would save
> cross-partition moves by default, making the move to the Downloads dir
> atomic (a single rename, which can fail, iterate until we find a "free"
> filename).
>
> Is that better for you?

Yep, it sounds better. Regarding renaming that is up the agent, if you
really want to do that its probably fine but Im still not convinced
this is absolutely necessary if obexd is running with the same user as
the agent can just create the file while authorizing so you wouldn't
need to move after completed, but again this is completely up to the
agent to decide where the files should go.

Btw, what about fd passing? In theory we can create a different
version of the agent interface to enable passing fd directly, and in
fact we were thinking about this already as for some services you
wanted them to be dynamic so we were thinking on having this set by
the agent when it registers.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH 1/3] gdbus: Don't try to remove removed sources
From: Johan Hedberg @ 2013-11-11  8:39 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth
In-Reply-To: <1384016577.3880.36.camel@nuvo>

Hi Bastien,

On Sat, Nov 09, 2013, Bastien Nocera wrote:
> When we return FALSE from idle handlers, the source is removed.
> This will be causing warnings in glib 2.40.
> 
> See https://bugzilla.gnome.org/show_bug.cgi?id=710724
> ---
>  gdbus/object.c | 3 +++
>  1 file changed, 3 insertions(+)

This patch has been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 1/3] android: Update bond state on incoming bonding
From: Johan Hedberg @ 2013-11-11  8:37 UTC (permalink / raw)
  To: Lukasz Rymanowski; +Cc: linux-bluetooth, szymon.janc
In-Reply-To: <1383925711-26374-2-git-send-email-lukasz.rymanowski@tieto.com>

Hi Lukasz,

On Fri, Nov 08, 2013, Lukasz Rymanowski wrote:
> Before sending any ssp request or pin code request up to HAL library we
> need to send bond state change with bonding state. Otherwise incoming
> bonding is impossible.
> ---
>  android/adapter.c | 21 ++++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)

Wont this cause HAL_BOND_STATE_BONDING to be sent twice if the pairing
was locally initiated through create_bond()?

Johan

^ permalink raw reply

* Re: [RFC] android/hid: Handle virtual unplug event from hid device
From: Johan Hedberg @ 2013-11-11  8:33 UTC (permalink / raw)
  To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383920094-20498-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Hi Ravi,

On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
> If hid host receives the virtual unplug event from hid device
> recipient shall destroy or invalidate all bluetooth bonding and
> virtual cable information
> ---
>  android/hal-msg.h |  1 +
>  android/hidhost.c | 28 ++++++++++++++++++++++++++++
>  2 files changed, 29 insertions(+)

Looks good enough to me, so the patch has been applied.

Johan

^ permalink raw reply

* Re: [PATCH 2/3] all: Use G_SOURCE_REMOVE/G_SOURCE_CONTINUE macros
From: Marcel Holtmann @ 2013-11-11  8:04 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <1384016586.3880.37.camel@nuvo>

Hi Bastien,

> Instead of TRUE/FALSE. This makes the source more readable.
> ---
> android/main.c                       |  4 ++--
> attrib/gattrib.c                     |  2 +-
> attrib/gatttool.c                    |  2 +-
> gdbus/mainloop.c                     |  6 +++---
> gdbus/object.c                       |  2 +-
> gdbus/watch.c                        |  2 +-
> gobex/gobex.c                        |  4 ++--
> obexd/client/session.c               |  4 ++--
> obexd/client/transfer.c              |  6 +++---
> obexd/plugins/messages-dummy.c       |  2 +-
> obexd/plugins/messages-tracker.c     |  2 +-
> obexd/plugins/phonebook-dummy.c      |  6 +++---
> plugins/policy.c                     |  6 +++---
> profiles/audio/a2dp.c                | 16 ++++++++--------
> profiles/audio/avctp.c               | 12 ++++++------
> profiles/audio/avdtp.c               | 14 +++++++-------
> profiles/audio/avrcp.c               |  2 +-
> profiles/audio/player.c              |  4 ++--
> profiles/cyclingspeed/cyclingspeed.c |  2 +-
> profiles/health/hdp.c                |  4 ++--
> profiles/health/mcap.c               |  2 +-
> profiles/health/mcap_sync.c          | 18 +++++++++---------
> profiles/input/device.c              | 10 +++++-----
> profiles/network/connection.c        |  2 +-
> profiles/proximity/monitor.c         |  4 ++--
> profiles/sap/server.c                |  4 ++--
> src/adapter.c                        | 20 ++++++++++----------
> src/device.c                         | 16 ++++++++--------
> src/main.c                           |  4 ++--
> src/sdp-client.c                     |  2 +-
> src/shared/hciemu.c                  |  2 +-
> src/shared/tester.c                  | 18 +++++++++---------
> tools/btiotest.c                     |  6 +++---
> unit/test-gdbus-client.c             |  4 ++--
> unit/test-gobex-transfer.c           |  2 +-
> unit/test-gobex.c                    |  4 ++--
> unit/test-sdp.c                      |  2 +-
> 37 files changed, 111 insertions(+), 111 deletions(-)
> 
> diff --git a/android/main.c b/android/main.c
> index 75004cf..a36269c 100644
> --- a/android/main.c
> +++ b/android/main.c
> @@ -377,7 +377,7 @@ static gboolean cmd_connect_cb(GIOChannel *io, GIOCondition cond,
> static gboolean quit_eventloop(gpointer user_data)
> {
> 	g_main_loop_quit(event_loop);
> -	return FALSE;
> +	return G_SOURCE_REMOVE;
> }

problem is that we currently only require GLib 2.28 and this got introduced in GLib 2.32.

Regards

Marcel


^ permalink raw reply

* [PATCH] obex: Use user's cache dir as a default root
From: Bastien Nocera @ 2013-11-10 14:24 UTC (permalink / raw)
  To: linux-bluetooth


It's per-user, so we won't try to overwrite somebody else's
files in /tmp when that happens. It's also (unless we have a
particularly bizarre setup) on the same partition as the destination
folder which means we can atomically move the file to the destination
with a unique filename.
---
 obexd/src/main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/obexd/src/main.c b/obexd/src/main.c
index 61a06b2..2f7d723 100644
--- a/obexd/src/main.c
+++ b/obexd/src/main.c
@@ -50,8 +50,6 @@
 #include "obexd.h"
 #include "server.h"
 
-#define DEFAULT_ROOT_PATH "/tmp"
-
 #define DEFAULT_CAP_FILE CONFIGDIR "/capability.xml"
 
 static GMainLoop *main_loop = NULL;
@@ -285,8 +283,10 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-	if (option_root == NULL)
-		option_root = g_strdup(DEFAULT_ROOT_PATH);
+	if (option_root == NULL) {
+		option_root = g_build_filename(g_get_user_cache_dir(), "obexd", NULL);
+		g_mkdir_with_parents(option_root, 0700);
+	}
 
 	if (option_root[0] != '/') {
 		char *old_root = option_root, *home = getenv("HOME");
-- 
1.8.4.2



^ permalink raw reply related

* Re: [PATCH 3/3] obex: Use XDG_RUNTIME_DIR as a default root
From: Bastien Nocera @ 2013-11-10 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1384016598.3880.38.camel@nuvo>

On Sat, 2013-11-09 at 18:03 +0100, Bastien Nocera wrote:
> It's per-user, so we won't try to overwrite somebody else's
> files in /tmp when that happens.

There might be another useful directory instead. We could use
g_get_user_cache_dir() instead of the run-time dir. This would save
cross-partition moves by default, making the move to the Downloads dir
atomic (a single rename, which can fail, iterate until we find a "free"
filename).

Is that better for you?

> ---
>  obexd/src/main.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/obexd/src/main.c b/obexd/src/main.c
> index 61a06b2..15777f5 100644
> --- a/obexd/src/main.c
> +++ b/obexd/src/main.c
> @@ -50,8 +50,6 @@
>  #include "obexd.h"
>  #include "server.h"
>  
> -#define DEFAULT_ROOT_PATH "/tmp"
> -
>  #define DEFAULT_CAP_FILE CONFIGDIR "/capability.xml"
>  
>  static GMainLoop *main_loop = NULL;
> @@ -286,7 +284,7 @@ int main(int argc, char *argv[])
>  	}
>  
>  	if (option_root == NULL)
> -		option_root = g_strdup(DEFAULT_ROOT_PATH);
> +		option_root = g_build_filename (g_get_user_runtime_dir (), "obexd", NULL);
>  
>  	if (option_root[0] != '/') {
>  		char *old_root = option_root, *home = getenv("HOME");



^ permalink raw reply

* Reading RSSI value from an RFCOMM connection
From: Michael Kehm @ 2013-11-10  6:31 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org

Hi folks,

I am trying to get the RSSI value from an established RFCOMM connection.
While searching on the Internet for hints I found the following discussions:
http://comments.gmane.org/gmane.linux.bluez.user/9986
http://stackoverflow.com/questions/2149295/android-2-1-how-do-i-poll-the-rssi-value-of-an-existing-bluetooth-connection
http://sourceforge.net/mailarchive/forum.php?forum_name=bluez-devel&style=nested&viewmonth=200505&viewday=17

Most suggestions point to the hci_read_rssi API (int hci_read_rssi(int dd, uint16_t handle, int8_t *rssi, int to);).
I am using Python. As a basic skeleton I am using Albert Huang's rfcomm-client.py and rfcomm-server.py scripts.
Looking into bluez.py and inquiry-with-rssi.py samples, it helped me to understand how to access the hci layer but I am stuck in execution.

This is my script based on rfcomm-server.py:

import os, sys, struct, fcntl, array, binascii
import btcommon
import bluetooth._bluetooth as _bt
from bluetooth import *

#################################################################
# Added code
def get_acl_conn_handle (hci_sock, addr):
    hci_fd = hci_sock.fileno ()
    reqstr = struct.pack ("6sB17s", _bt.str2ba (addr), _bt.ACL_LINK, "\0" * 17)
    request = array.array ("c", reqstr)

    print "ACL_LINK:%s" % _bt.ACL_LINK
    print "hci_fd:%s" % hci_fd
    print "HCIGETCONNINFO:%s" % _bt.HCIGETCONNINFO
    print "request:%s" % request
    fcntl.ioctl (hci_fd, _bt.HCIGETCONNINFO, request, 1)

    try:
        fcntl.ioctl (hci_fd, _bt.HCIGETCONNINFO, request, 1)
    except IOError, e:
        raise BluetoothError ("There is no ACL connection to %s" % addr)

    # XXX should this be "<8xH14x"?
    handle = struct.unpack ("8xH14x", request.tostring ())[0]
    return handle
#################################################################

server_sock=BluetoothSocket( RFCOMM )
server_sock.bind(("",PORT_ANY))
server_sock.listen(1)

port = server_sock.getsockname()[1]

uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee"

advertise_service( server_sock, "SampleServer",
                   service_id = uuid,
                   service_classes = [ uuid, SERIAL_PORT_CLASS ],
                   profiles = [ SERIAL_PORT_PROFILE ], 
#                   protocols = [ OBEX_UUID ] 
                    )
                   
print "Waiting for connection on RFCOMM channel %d" % port

client_sock, client_info = server_sock.accept()
print "Accepted connection from ", client_info

#################################################################
# Added code
rssi = 0
handle = get_acl_conn_handle(server_sock._sock, client_info[0])
rssi = bluez.hci_read_rssi(server_sock._sock, handle, rssi, 1000)
#################################################################

try:
    client_sock.send(rssi)
    print "sent [%s]" % rssi
        
except IOError:
    pass

print "disconnected"

client_sock.close()
server_sock.close()
print "all done"


I have added/copied the get_acl_conn_handle function and the call to hci_read_rssi.
The problem is that I run into the following exception:

Traceback (most recent call last):
  File "rfcomm-rssi.py", line 48, in <module>
    handle = get_acl_conn_handle(server_sock._sock, client_info[0])
  File "rfcomm-rssi.py", line 16, in get_acl_conn_handle
    fcntl.ioctl (hci_fd, _bt.HCIGETCONNINFO, request, 1)
IOError: [Errno 22] Invalid argument


The print statements in get_acl_conn_handle return the following information:

ACL_LINK:1
hci_fd:3
HCIGETCONNINFO:-2147202859
request:array('c', '9\x91\x97g\x1d\x1c\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')


I am bit lost on how to fix this. 
If anyone can help me with my script above or if anyone has sample code in Python or C how to get the RSSI data from a RFCOMM connection then I would highly appreciate it.

Thanks in advance,
Michael

^ permalink raw reply

* Re: obexd broken for absolute paths
From: Bastien Nocera @ 2013-11-10  0:59 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZJyKT65rUxdhtkQit3ok4Y7khHF0qjROL1-0YzZUUbMiA@mail.gmail.com>

On Sun, 2013-11-10 at 02:49 +0200, Luiz Augusto von Dentz wrote:
> Hi Bastian,
> 
> On Sat, Nov 9, 2013 at 11:00 PM, Bastien Nocera <hadess@hadess.net> wrote:
> > On Sat, 2013-11-09 at 20:35 +0200, Luiz Augusto von Dentz wrote:
> >> Hi Bastian,
> >>
> >> On Sat, Nov 9, 2013 at 7:17 PM, Bastien Nocera <hadess@hadess.net> wrote:
> >> > On Fri, 2013-11-08 at 20:21 +0100, Bastien Nocera wrote:
> >> >> Heya,
> >> >>
> >> >> I was trying to test gnome-user-share's Bluetooth support for BlueZ 5,
> >> >> and was quite surprised it didn't work one bit, with transfers failing
> >> >> as soon as they were created.
> >> >>
> >> >> I made this simple change to test/simple-obex-agent so you could
> >> >> replicate the failure. Obviously, change the download path to exist on
> >> >> your system:
> >> >> -               return properties['Name']
> >> >> +               return ("%s/%s" % ("/home/hadess/Downloads/", properties['Name']))
> >> >>
> >> >> This will see OBEX Push transfers fail as soon as accepted.
> >> >
> >> > Turns out this is a feature of filesystem plugin in obexd, and a bit of
> >> > a problem as well:
> >> > - There's no way to change the folder without changing the service file
> >>
> >> Yep, I remember discussing with Gustavo Padovan that this should
> >> probably be set by the agent upon registration.
> >
> > I thought about that, but it's really a security issue. obexd might be
> > running in a different context than the "application" telling it where
> > to write. For example, my share application might be restricted to write
> > new files in ~/Downloads, but could tell obexd to write to ~/.ssh/etc.
> 
> If obexd is running with a different user then yes, but I don't think
> this is the case otherwise we should pass fd not a path since the
> files should really belong to the agent not obexd.

Not a different user, a different security context, which is going to
happen when applications are sandboxed within the session.

> >> > - It doesn't default to use the XDG_RUNTIME_DIR
> >>
> >> That is a good default considering we don't implement the change
> >> above, otherwise for auto accept I believe tmp is usually a better
> >> option.
> >
> > This is what I intend to use in gnome-user-share. obexd would write
> > files with unique filenames to /run/user/<id>/obexd and move it
> > ~/Downloads after uniquifying the name (eg. sending 2 files called
> > "foo.jpg" should give me 2 files, not overwrite the first one as it does
> > now).
> 
> Not sure what is the point of doing this, except if you want to use
> tmpfs while downloading and only really store on disk when the
> transfer is complete, overwrite is agent problem to select different
> path if the file already exist or alert the user it will overwrite.

There's no way of doing this in a race-free way. The right way to do
this would be for the agent to return a file descriptor, not a path.

A file with that path might be created between the time the filename is
considered "free" by the agent and obexd actually writing it. It might
even be racy when receiving multiple files with the same name.


^ permalink raw reply

* Re: obexd broken for absolute paths
From: Luiz Augusto von Dentz @ 2013-11-10  0:49 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1384030812.3880.47.camel@nuvo>

Hi Bastian,

On Sat, Nov 9, 2013 at 11:00 PM, Bastien Nocera <hadess@hadess.net> wrote:
> On Sat, 2013-11-09 at 20:35 +0200, Luiz Augusto von Dentz wrote:
>> Hi Bastian,
>>
>> On Sat, Nov 9, 2013 at 7:17 PM, Bastien Nocera <hadess@hadess.net> wrote:
>> > On Fri, 2013-11-08 at 20:21 +0100, Bastien Nocera wrote:
>> >> Heya,
>> >>
>> >> I was trying to test gnome-user-share's Bluetooth support for BlueZ 5,
>> >> and was quite surprised it didn't work one bit, with transfers failing
>> >> as soon as they were created.
>> >>
>> >> I made this simple change to test/simple-obex-agent so you could
>> >> replicate the failure. Obviously, change the download path to exist on
>> >> your system:
>> >> -               return properties['Name']
>> >> +               return ("%s/%s" % ("/home/hadess/Downloads/", properties['Name']))
>> >>
>> >> This will see OBEX Push transfers fail as soon as accepted.
>> >
>> > Turns out this is a feature of filesystem plugin in obexd, and a bit of
>> > a problem as well:
>> > - There's no way to change the folder without changing the service file
>>
>> Yep, I remember discussing with Gustavo Padovan that this should
>> probably be set by the agent upon registration.
>
> I thought about that, but it's really a security issue. obexd might be
> running in a different context than the "application" telling it where
> to write. For example, my share application might be restricted to write
> new files in ~/Downloads, but could tell obexd to write to ~/.ssh/etc.

If obexd is running with a different user then yes, but I don't think
this is the case otherwise we should pass fd not a path since the
files should really belong to the agent not obexd.

>> > - It doesn't default to use the XDG_RUNTIME_DIR
>>
>> That is a good default considering we don't implement the change
>> above, otherwise for auto accept I believe tmp is usually a better
>> option.
>
> This is what I intend to use in gnome-user-share. obexd would write
> files with unique filenames to /run/user/<id>/obexd and move it
> ~/Downloads after uniquifying the name (eg. sending 2 files called
> "foo.jpg" should give me 2 files, not overwrite the first one as it does
> now).

Not sure what is the point of doing this, except if you want to use
tmpfs while downloading and only really store on disk when the
transfer is complete, overwrite is agent problem to select different
path if the file already exist or alert the user it will overwrite.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Debugging broken audio stream
From: Stanisław Pitucha @ 2013-11-09 22:33 UTC (permalink / raw)
  To: linux-bluetooth

Hi all,
I'm having issues with using a remote audio sink device and I can't
find any clear indications of a problem.

My current config is:
- kernel 3.11.6 (x86_64)
- bluez 5.10
- pulseaudio 4.0
- ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 [ThinkPad]  (btusb driver)

The receiving device is Logitech's wireless audio adapter.

When sending data from android devices (4.1, 4.3) everything works
without issues, so I think the receiver seems ok.

On the laptop side which is having problems, the initial connection /
pairing works without issues, but the sound stream is very unstable
(unusable really: 1 second of sound, 5 of silence, repeat...) and
sometimes the connection drops / reconnects on its own. Sometimes it
works for a couple of seconds before failing.
Sometimes there's a stacktrace reported from the kernel (see
https://bugs.archlinux.org/task/37697 ), but not always.
The debug output from bluetoothd doesn't report any specific issues
(as far as I can tell from the log) until it disconnects completely
("Abort: Connection timed out (110)")
A full session in debug mode (connect, try to play some music,
connection times out, tries playing again, killing bluez) is available
at http://pastebin.com/n7qfumYR

Syslog contains pages of repeated messages like this (different
time/sizes in each line, chosen smallest/biggest I can see):
Nov 09 20:14:00 gumby pulseaudio[19585]: [bluetooth]
module-bluez5-device.c: Skipping 116 us (= 20 bytes) in audio stream
...
Nov 09 20:14:03 gumby pulseaudio[19585]: [bluetooth]
module-bluez5-device.c: Skipping 564192 us (= 99520 bytes) in audio
stream
I'm not sure how to prove the issue is definitely on either the bluez,
or pulseaudio's side...

What more can I do in this case? What other debugging options do I
have? Would capturing the bluetooth packets be useful at all?
I assume the bluetooth in laptop is not damaged/unsupported, because I
can exchange files between it and the android devices.

Any/all help appreciated.

-- 
KTHXBYE,

Stanisław Pitucha

^ permalink raw reply

* Re: obexd broken for absolute paths
From: Bastien Nocera @ 2013-11-09 21:00 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZJtvdd0iDmcuUe7S9mi68U1nQOLTy577vu0T-kpa9wMBA@mail.gmail.com>

On Sat, 2013-11-09 at 20:35 +0200, Luiz Augusto von Dentz wrote:
> Hi Bastian,
> 
> On Sat, Nov 9, 2013 at 7:17 PM, Bastien Nocera <hadess@hadess.net> wrote:
> > On Fri, 2013-11-08 at 20:21 +0100, Bastien Nocera wrote:
> >> Heya,
> >>
> >> I was trying to test gnome-user-share's Bluetooth support for BlueZ 5,
> >> and was quite surprised it didn't work one bit, with transfers failing
> >> as soon as they were created.
> >>
> >> I made this simple change to test/simple-obex-agent so you could
> >> replicate the failure. Obviously, change the download path to exist on
> >> your system:
> >> -               return properties['Name']
> >> +               return ("%s/%s" % ("/home/hadess/Downloads/", properties['Name']))
> >>
> >> This will see OBEX Push transfers fail as soon as accepted.
> >
> > Turns out this is a feature of filesystem plugin in obexd, and a bit of
> > a problem as well:
> > - There's no way to change the folder without changing the service file
> 
> Yep, I remember discussing with Gustavo Padovan that this should
> probably be set by the agent upon registration.

I thought about that, but it's really a security issue. obexd might be
running in a different context than the "application" telling it where
to write. For example, my share application might be restricted to write
new files in ~/Downloads, but could tell obexd to write to ~/.ssh/etc.

> > - It doesn't default to use the XDG_RUNTIME_DIR
> 
> That is a good default considering we don't implement the change
> above, otherwise for auto accept I believe tmp is usually a better
> option.

This is what I intend to use in gnome-user-share. obexd would write
files with unique filenames to /run/user/<id>/obexd and move it
~/Downloads after uniquifying the name (eg. sending 2 files called
"foo.jpg" should give me 2 files, not overwrite the first one as it does
now).

Cheers


^ permalink raw reply

* Re: obexd broken for absolute paths
From: Luiz Augusto von Dentz @ 2013-11-09 18:35 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1384017476.3880.40.camel@nuvo>

Hi Bastian,

On Sat, Nov 9, 2013 at 7:17 PM, Bastien Nocera <hadess@hadess.net> wrote:
> On Fri, 2013-11-08 at 20:21 +0100, Bastien Nocera wrote:
>> Heya,
>>
>> I was trying to test gnome-user-share's Bluetooth support for BlueZ 5,
>> and was quite surprised it didn't work one bit, with transfers failing
>> as soon as they were created.
>>
>> I made this simple change to test/simple-obex-agent so you could
>> replicate the failure. Obviously, change the download path to exist on
>> your system:
>> -               return properties['Name']
>> +               return ("%s/%s" % ("/home/hadess/Downloads/", properties['Name']))
>>
>> This will see OBEX Push transfers fail as soon as accepted.
>
> Turns out this is a feature of filesystem plugin in obexd, and a bit of
> a problem as well:
> - There's no way to change the folder without changing the service file

Yep, I remember discussing with Gustavo Padovan that this should
probably be set by the agent upon registration.

> - It doesn't default to use the XDG_RUNTIME_DIR

That is a good default considering we don't implement the change
above, otherwise for auto accept I believe tmp is usually a better
option.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* [PATCH] obex: Use GLib helper function to manipulate paths
From: Bastien Nocera @ 2013-11-09 17:18 UTC (permalink / raw)
  To: linux-bluetooth


Instead of trying to do it by hand. This also makes sure that
relative paths aren't used by the agent.
---
 obexd/src/manager.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index cec8a39..f18896e 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -651,14 +651,14 @@ static void agent_reply(DBusPendingCall *call, void *user_data)
 				DBUS_TYPE_STRING, &name,
 				DBUS_TYPE_INVALID)) {
 		/* Splits folder and name */
-		const char *slash = strrchr(name, '/');
+		gboolean is_relative = !g_path_is_absolute(name);
 		DBG("Agent replied with %s", name);
-		if (!slash) {
-			agent->new_name = g_strdup(name);
+		if (is_relative) {
+			agent->new_name = g_path_get_basename(name);
 			agent->new_folder = NULL;
 		} else {
-			agent->new_name = g_strdup(slash + 1);
-			agent->new_folder = g_strndup(name, slash - name);
+			agent->new_name = g_path_get_basename(name);
+			agent->new_folder = g_path_get_dirname(name);
 		}
 	}
 
-- 
1.8.4.2



^ permalink raw reply related

* Re: obexd broken for absolute paths
From: Bastien Nocera @ 2013-11-09 17:17 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1383938500.3880.23.camel@nuvo>

On Fri, 2013-11-08 at 20:21 +0100, Bastien Nocera wrote:
> Heya,
> 
> I was trying to test gnome-user-share's Bluetooth support for BlueZ 5,
> and was quite surprised it didn't work one bit, with transfers failing
> as soon as they were created.
> 
> I made this simple change to test/simple-obex-agent so you could
> replicate the failure. Obviously, change the download path to exist on
> your system:
> -               return properties['Name']
> +               return ("%s/%s" % ("/home/hadess/Downloads/", properties['Name']))
> 
> This will see OBEX Push transfers fail as soon as accepted.

Turns out this is a feature of filesystem plugin in obexd, and a bit of
a problem as well:
- There's no way to change the folder without changing the service file
- It doesn't default to use the XDG_RUNTIME_DIR 

> I must also mention the dreadful code in agent_reply() in obexd/src/manager.c:
>                 const char *slash = strrchr(name, '/');
>                 DBG("Agent replied with %s", name);
>                 if (!slash) {
>                         agent->new_name = g_strdup(name);
>                         agent->new_folder = NULL;
>                 } else {
>                         agent->new_name = g_strdup(slash + 1); 
>                         agent->new_folder = g_strndup(name, slash - name);
>                 }
> 
> Please use g_path_get_basename() and g_path_get_dirname(). This is even
> a security issue because I could pass relative paths and expect some
> system file to get overwritten.

I've sent a patch for this.

Cheers


^ permalink raw reply

* Re: [PATCH 1/3] gdbus: Don't try to remove removed sources
From: Bastien Nocera @ 2013-11-09 17:04 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1384016577.3880.36.camel@nuvo>

On Sat, 2013-11-09 at 18:02 +0100, Bastien Nocera wrote:
> When we return FALSE from idle handlers, the source is removed.
> This will be causing warnings in glib 2.40.
> 
> See https://bugzilla.gnome.org/show_bug.cgi?id=710724

Note that there's plenty of other places where this should be fixed.
I'll leave those up to somebody who doesn't get RSI ;)


^ permalink raw reply

* [PATCH 3/3] obex: Use XDG_RUNTIME_DIR as a default root
From: Bastien Nocera @ 2013-11-09 17:03 UTC (permalink / raw)
  To: linux-bluetooth


It's per-user, so we won't try to overwrite somebody else's
files in /tmp when that happens.
---
 obexd/src/main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/obexd/src/main.c b/obexd/src/main.c
index 61a06b2..15777f5 100644
--- a/obexd/src/main.c
+++ b/obexd/src/main.c
@@ -50,8 +50,6 @@
 #include "obexd.h"
 #include "server.h"
 
-#define DEFAULT_ROOT_PATH "/tmp"
-
 #define DEFAULT_CAP_FILE CONFIGDIR "/capability.xml"
 
 static GMainLoop *main_loop = NULL;
@@ -286,7 +284,7 @@ int main(int argc, char *argv[])
 	}
 
 	if (option_root == NULL)
-		option_root = g_strdup(DEFAULT_ROOT_PATH);
+		option_root = g_build_filename (g_get_user_runtime_dir (), "obexd", NULL);
 
 	if (option_root[0] != '/') {
 		char *old_root = option_root, *home = getenv("HOME");
-- 
1.8.4.2



^ permalink raw reply related

* [PATCH 2/3] all: Use G_SOURCE_REMOVE/G_SOURCE_CONTINUE macros
From: Bastien Nocera @ 2013-11-09 17:03 UTC (permalink / raw)
  To: linux-bluetooth


Instead of TRUE/FALSE. This makes the source more readable.
---
 android/main.c                       |  4 ++--
 attrib/gattrib.c                     |  2 +-
 attrib/gatttool.c                    |  2 +-
 gdbus/mainloop.c                     |  6 +++---
 gdbus/object.c                       |  2 +-
 gdbus/watch.c                        |  2 +-
 gobex/gobex.c                        |  4 ++--
 obexd/client/session.c               |  4 ++--
 obexd/client/transfer.c              |  6 +++---
 obexd/plugins/messages-dummy.c       |  2 +-
 obexd/plugins/messages-tracker.c     |  2 +-
 obexd/plugins/phonebook-dummy.c      |  6 +++---
 plugins/policy.c                     |  6 +++---
 profiles/audio/a2dp.c                | 16 ++++++++--------
 profiles/audio/avctp.c               | 12 ++++++------
 profiles/audio/avdtp.c               | 14 +++++++-------
 profiles/audio/avrcp.c               |  2 +-
 profiles/audio/player.c              |  4 ++--
 profiles/cyclingspeed/cyclingspeed.c |  2 +-
 profiles/health/hdp.c                |  4 ++--
 profiles/health/mcap.c               |  2 +-
 profiles/health/mcap_sync.c          | 18 +++++++++---------
 profiles/input/device.c              | 10 +++++-----
 profiles/network/connection.c        |  2 +-
 profiles/proximity/monitor.c         |  4 ++--
 profiles/sap/server.c                |  4 ++--
 src/adapter.c                        | 20 ++++++++++----------
 src/device.c                         | 16 ++++++++--------
 src/main.c                           |  4 ++--
 src/sdp-client.c                     |  2 +-
 src/shared/hciemu.c                  |  2 +-
 src/shared/tester.c                  | 18 +++++++++---------
 tools/btiotest.c                     |  6 +++---
 unit/test-gdbus-client.c             |  4 ++--
 unit/test-gobex-transfer.c           |  2 +-
 unit/test-gobex.c                    |  4 ++--
 unit/test-sdp.c                      |  2 +-
 37 files changed, 111 insertions(+), 111 deletions(-)

diff --git a/android/main.c b/android/main.c
index 75004cf..a36269c 100644
--- a/android/main.c
+++ b/android/main.c
@@ -377,7 +377,7 @@ static gboolean cmd_connect_cb(GIOChannel *io, GIOCondition cond,
 static gboolean quit_eventloop(gpointer user_data)
 {
 	g_main_loop_quit(event_loop);
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
@@ -524,7 +524,7 @@ static gboolean adapter_timeout_handler(gpointer user_data)
 	adapter_timeout = 0;
 	g_main_loop_quit(event_loop);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void read_index_list_complete(uint8_t status, uint16_t length,
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 609b908..4d93902 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -284,7 +284,7 @@ done:
 
 	g_attrib_unref(attrib);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean can_write_data(GIOChannel *io, GIOCondition cond,
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index f211dcd..7ef26aa 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -116,7 +116,7 @@ static gboolean listen_start(gpointer user_data)
 	g_attrib_register(attrib, ATT_OP_HANDLE_IND, GATTRIB_ALL_HANDLES,
 						events_handler, attrib, NULL);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c
index 099b67f..d00db33 100644
--- a/gdbus/mainloop.c
+++ b/gdbus/mainloop.c
@@ -77,7 +77,7 @@ static gboolean message_dispatch(void *data)
 
 	dbus_connection_unref(conn);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static inline void queue_dispatch(DBusConnection *conn,
@@ -186,11 +186,11 @@ static gboolean timeout_handler_dispatch(gpointer data)
 
 	/* if not enabled should not be polled by the main loop */
 	if (!dbus_timeout_get_enabled(handler->timeout))
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	dbus_timeout_handle(handler->timeout);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void timeout_handler_free(void *data)
diff --git a/gdbus/object.c b/gdbus/object.c
index b248cbb..72c542e 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1008,7 +1008,7 @@ static gboolean process_changes(gpointer user_data)
 
 	data->process_id = 0;
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void generic_unregister(DBusConnection *connection, void *user_data)
diff --git a/gdbus/watch.c b/gdbus/watch.c
index 0f99f4f..f357cd1 100644
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -599,7 +599,7 @@ static gboolean update_service(void *user_data)
 
 	dbus_connection_unref(conn);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void service_reply(DBusPendingCall *call, void *user_data)
diff --git a/gobex/gobex.c b/gobex/gobex.c
index 8c08b1e..e107c0c 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -253,7 +253,7 @@ static gboolean req_timeout(gpointer user_data)
 	g_error_free(err);
 	pending_pkt_free(p);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean write_stream(GObex *obex, GError **err)
@@ -720,7 +720,7 @@ static gboolean cancel_complete(gpointer user_data)
 
 	pending_pkt_free(p);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 gboolean g_obex_cancel_req(GObex *obex, guint req_id, gboolean remove_callback)
diff --git a/obexd/client/session.c b/obexd/client/session.c
index 8138b1e..72fcc6d 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
@@ -435,7 +435,7 @@ static gboolean connection_complete(gpointer data)
 
 	g_free(cb);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static int session_connect(struct obc_session *session,
@@ -730,7 +730,7 @@ static gboolean session_process(gpointer data)
 
 	session_process_queue(session);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void session_queue(struct pending_request *p)
diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c
index 5a8d4f2..54713a9 100644
--- a/obexd/client/transfer.c
+++ b/obexd/client/transfer.c
@@ -680,13 +680,13 @@ static gboolean report_progress(gpointer data)
 	struct obc_transfer *transfer = data;
 
 	if (transfer->transferred == transfer->progress)
-		return TRUE;
+		return G_SOURCE_CONTINUE;
 
 	transfer->progress = transfer->transferred;
 
 	if (transfer->transferred == transfer->size) {
 		transfer->progress_id = 0;
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	if (transfer->status != TRANSFER_STATUS_ACTIVE)
@@ -695,7 +695,7 @@ static gboolean report_progress(gpointer data)
 	g_dbus_emit_property_changed(transfer->conn, transfer->path,
 					TRANSFER_INTERFACE, "Transferred");
 
-	return TRUE;
+	return G_SOURCE_CONTINUE;
 }
 
 static gboolean transfer_start_get(struct obc_transfer *transfer, GError **err)
diff --git a/obexd/plugins/messages-dummy.c b/obexd/plugins/messages-dummy.c
index bb0627f..439ea95 100644
--- a/obexd/plugins/messages-dummy.c
+++ b/obexd/plugins/messages-dummy.c
@@ -198,7 +198,7 @@ static gboolean get_folder_listing(void *d)
 	return_folder_listing(fld, list);
 	g_slist_free_full(list, g_free);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 int messages_init(void)
diff --git a/obexd/plugins/messages-tracker.c b/obexd/plugins/messages-tracker.c
index 60f3a80..6df57ad 100644
--- a/obexd/plugins/messages-tracker.c
+++ b/obexd/plugins/messages-tracker.c
@@ -282,7 +282,7 @@ static gboolean async_get_folder_listing(void *s)
 	g_free(path);
 	g_free(session->name);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 int messages_get_folder_listing(void *s, const char *name,
diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c
index 6b9d040..ca266ef 100644
--- a/obexd/plugins/phonebook-dummy.c
+++ b/obexd/plugins/phonebook-dummy.c
@@ -252,7 +252,7 @@ done:
 
 	g_string_free(buffer, TRUE);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void entry_notify(const char *filename, VObject *v, void *user_data)
@@ -326,7 +326,7 @@ static gboolean create_cache(void *user_data)
 
 	query->ready_cb(query->user_data);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean read_entry(void *user_data)
@@ -348,7 +348,7 @@ static gboolean read_entry(void *user_data)
 
 	dummy->cb(buffer, count, 1, 0, TRUE, dummy->user_data);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean is_dir(const char *dir)
diff --git a/plugins/policy.c b/plugins/policy.c
index 0292482..787371f 100644
--- a/plugins/policy.c
+++ b/plugins/policy.c
@@ -90,7 +90,7 @@ static gboolean policy_connect_ct(gpointer user_data)
 	if (service != NULL)
 		policy_connect(data, service);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void policy_set_ct_timer(struct policy_data *data)
@@ -163,7 +163,7 @@ static gboolean policy_connect_sink(gpointer user_data)
 	if (service != NULL)
 		policy_connect(data, service);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void policy_set_sink_timer(struct policy_data *data)
@@ -272,7 +272,7 @@ static gboolean policy_connect_source(gpointer user_data)
 	if (service != NULL)
 		policy_connect(data, service);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void policy_set_source_timer(struct policy_data *data)
diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 8477b5d..1299171 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -224,7 +224,7 @@ static gboolean finalize_config(gpointer data)
 		setup_cb_free(cb);
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean finalize_resume(gpointer data)
@@ -244,7 +244,7 @@ static gboolean finalize_resume(gpointer data)
 		setup_cb_free(cb);
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean finalize_suspend(gpointer data)
@@ -264,7 +264,7 @@ static gboolean finalize_suspend(gpointer data)
 		setup_cb_free(cb);
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void finalize_select(struct a2dp_setup *s)
@@ -384,7 +384,7 @@ static gboolean auto_config(gpointer data)
 
 	/* Check if configuration was aborted */
 	if (setup->sep->stream == NULL)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	if (setup->err != NULL)
 		goto done;
@@ -413,7 +413,7 @@ done:
 
 	setup_unref(setup);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void endpoint_setconf_cb(struct a2dp_setup *setup, gboolean ret)
@@ -727,7 +727,7 @@ static gboolean suspend_timeout(struct a2dp_sep *sep)
 	avdtp_unref(sep->session);
 	sep->session = NULL;
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean start_ind(struct avdtp *session, struct avdtp_local_sep *sep,
@@ -928,11 +928,11 @@ static gboolean a2dp_reconfigure(gpointer data)
 		goto failed;
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 
 failed:
 	finalize_setup_errno(setup, posix_err, finalize_config, NULL);
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void close_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index dac7a66..fb1a167 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -299,7 +299,7 @@ static gboolean auto_release(gpointer user_data)
 
 	send_key(session->uinput, session->key.op, 0);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static size_t handle_panel_passthrough(struct avctp *session,
@@ -697,7 +697,7 @@ static gboolean req_timeout(gpointer user_data)
 	if (chan->process_id == 0)
 		chan->process_id = g_idle_add(process_queue, chan);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static int process_control(void *data)
@@ -727,7 +727,7 @@ static gboolean process_queue(void *user_data)
 	chan->process_id = 0;
 
 	if (p != NULL)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	while ((p = g_queue_pop_head(chan->queue))) {
 
@@ -738,12 +738,12 @@ static gboolean process_queue(void *user_data)
 	}
 
 	if (p == NULL)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	chan->p = p;
 	p->timeout = g_timeout_add_seconds(2, req_timeout, chan);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 
 }
 
@@ -1653,7 +1653,7 @@ static gboolean repeat_timeout(gpointer user_data)
 	avctp_passthrough_release(session, session->key.op);
 	avctp_passthrough_press(session, session->key.op);
 
-	return TRUE;
+	return G_SOURCE_CONTINUE;
 }
 
 static void release_pressed(struct avctp *session)
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index dab8f1c..ccbd117 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -630,7 +630,7 @@ static gboolean stream_close_timeout(gpointer user_data)
 
 	close_stream(stream);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean stream_open_timeout(gpointer user_data)
@@ -645,7 +645,7 @@ static gboolean stream_open_timeout(gpointer user_data)
 
 	avdtp_abort(stream->session, stream);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 void avdtp_error_init(struct avdtp_error *err, uint8_t category, int id)
@@ -1181,18 +1181,18 @@ static gboolean disconnect_timeout(gpointer user_data)
 	service = btd_device_get_service(session->device, A2DP_SINK_UUID);
 	if (service && stream_setup) {
 		sink_setup_stream(service, session);
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	service = btd_device_get_service(session->device, A2DP_SOURCE_UUID);
 	if (service && stream_setup) {
 		source_setup_stream(service, session);
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	connection_lost(session, ETIMEDOUT);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void set_disconnect_timer(struct avdtp *session)
@@ -2675,7 +2675,7 @@ static gboolean request_timeout(gpointer user_data)
 
 	cancel_request(session, ETIMEDOUT);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static int send_req(struct avdtp *session, gboolean priority,
@@ -3332,7 +3332,7 @@ static gboolean process_discover(gpointer data)
 
 	finalize_discovery(session, 0);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 int avdtp_discover(struct avdtp *session, avdtp_discover_cb_t cb,
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index cd027c6..b3a1873 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -3323,7 +3323,7 @@ static gboolean connect_browsing(gpointer user_data)
 
 	avctp_connect_browsing(session->conn);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void avrcp_connect_browsing(struct avrcp *session)
diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index 6150c8a..bce72e9 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -1306,13 +1306,13 @@ static gboolean process_metadata_changed(void *user_data)
 
 	item = g_hash_table_lookup(mp->track, "Item");
 	if (item == NULL)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	g_dbus_emit_property_changed(btd_get_dbus_connection(),
 					item, MEDIA_ITEM_INTERFACE,
 					"Metadata");
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 void media_player_set_metadata(struct media_player *mp,
diff --git a/profiles/cyclingspeed/cyclingspeed.c b/profiles/cyclingspeed/cyclingspeed.c
index 6ecc985..3ad9e75 100644
--- a/profiles/cyclingspeed/cyclingspeed.c
+++ b/profiles/cyclingspeed/cyclingspeed.c
@@ -307,7 +307,7 @@ static gboolean controlpoint_timeout(gpointer user_data)
 	req->csc->pending_req = NULL;
 	g_free(req);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void controlpoint_write_cb(guint8 status, const guint8 *pdu, guint16 len,
diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
index 7b4e799..d7d0699 100644
--- a/profiles/health/hdp.c
+++ b/profiles/health/hdp.c
@@ -1536,12 +1536,12 @@ static gboolean echo_timeout(gpointer data)
 
 	fd = mcap_mdl_get_fd(chan->mdl);
 	if (fd < 0)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	io = g_io_channel_unix_new(fd);
 	g_io_channel_shutdown(io, TRUE, NULL);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void hdp_echo_connect_cb(struct mcap_mdl *mdl, GError *err,
diff --git a/profiles/health/mcap.c b/profiles/health/mcap.c
index 6d821f3..37b5789 100644
--- a/profiles/health/mcap.c
+++ b/profiles/health/mcap.c
@@ -463,7 +463,7 @@ static gboolean wait_response_timer(gpointer data)
 	mcl->mi->mcl_disconnected_cb(mcl, mcl->mi->user_data);
 	mcap_cache_mcl(mcl);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 gboolean mcap_create_mdl(struct mcap_mcl *mcl,
diff --git a/profiles/health/mcap_sync.c b/profiles/health/mcap_sync.c
index 0d9f17d..aea0202 100644
--- a/profiles/health/mcap_sync.c
+++ b/profiles/health/mcap_sync.c
@@ -517,15 +517,15 @@ static gboolean sync_send_indication(gpointer user_data)
 	int sent;
 
 	if (!user_data)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	mcl = user_data;
 
 	if (!caps(mcl))
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	if (!get_all_clocks(mcl, &btclock, &base_time, &tmstamp))
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	cmd = g_new0(mcap_md_sync_info_ind, 1);
 
@@ -557,12 +557,12 @@ static gboolean proc_sync_set_req_phase2(gpointer user_data)
 	int delay;
 
 	if (!user_data)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	mcl = user_data;
 
 	if (!mcl->csp->set_data)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	data = mcl->csp->set_data;
 	update = data->update;
@@ -573,17 +573,17 @@ static gboolean proc_sync_set_req_phase2(gpointer user_data)
 
 	if (!caps(mcl)) {
 		send_sync_set_rsp(mcl, MCAP_UNSPECIFIED_ERROR, 0, 0, 0);
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	if (!get_all_clocks(mcl, &btclock, &base_time, &tmstamp)) {
 		send_sync_set_rsp(mcl, MCAP_UNSPECIFIED_ERROR, 0, 0, 0);
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	if (get_btrole(mcl) != role) {
 		send_sync_set_rsp(mcl, MCAP_INVALID_OPERATION, 0, 0, 0);
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	reset = (new_tmstamp != MCAP_TMSTAMP_DONTSET);
@@ -624,7 +624,7 @@ static gboolean proc_sync_set_req_phase2(gpointer user_data)
 	if (update)
 		sync_send_indication(mcl);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void proc_sync_set_req(struct mcap_mcl *mcl, uint8_t *cmd, uint32_t len)
diff --git a/profiles/input/device.c b/profiles/input/device.c
index 6523161..bd0886e 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -668,23 +668,23 @@ static gboolean input_device_auto_reconnect(gpointer user_data)
 	 * or is marked for removal. */
 	if (device_is_temporary(idev->device) ||
 					device_is_connected(idev->device))
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	/* Only attempt an auto-reconnect for at most 3 minutes (6 * 30s). */
 	if (idev->reconnect_attempt >= 6)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	/* Check if the profile is already connected. */
 	if (idev->ctrl_io)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	if (is_connected(idev))
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	idev->reconnect_attempt++;
 	dev_connect(idev);
 
-	return TRUE;
+	return G_SOURCE_CONTINUE;
 }
 
 static const char * const _reconnect_mode_str[] = {
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index 960a1fe..5008ea1 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -354,7 +354,7 @@ static gboolean bnep_conn_req_to(gpointer user_data)
 
 	cancel_connection(nc, -ETIMEDOUT);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static int bnep_connect(struct network_conn *nc)
diff --git a/profiles/proximity/monitor.c b/profiles/proximity/monitor.c
index eaa5b0d..a894235 100644
--- a/profiles/proximity/monitor.c
+++ b/profiles/proximity/monitor.c
@@ -304,7 +304,7 @@ static gboolean immediate_timeout(gpointer user_data)
 	monitor->immediateto = 0;
 
 	if (g_strcmp0(monitor->immediatelevel, "none") == 0)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	if (monitor->attrib) {
 		uint8_t value = ALERT_NONE;
@@ -319,7 +319,7 @@ static gboolean immediate_timeout(gpointer user_data)
 	g_dbus_emit_property_changed(btd_get_dbus_connection(), path,
 				PROXIMITY_INTERFACE, "ImmediateAlertLevel");
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void immediate_written(gpointer user_data)
diff --git a/profiles/sap/server.c b/profiles/sap/server.c
index 63314a7..81a5c58 100644
--- a/profiles/sap/server.c
+++ b/profiles/sap/server.c
@@ -583,7 +583,7 @@ static gboolean guard_timeout(gpointer data)
 	struct sap_connection *conn = server->conn;
 
 	if (!conn)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	DBG("conn %p state %d pr 0x%02x", conn, conn->state,
 						conn->processing_req);
@@ -613,7 +613,7 @@ static gboolean guard_timeout(gpointer data)
 		break;
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void sap_set_connected(struct sap_server *server)
diff --git a/src/adapter.c b/src/adapter.c
index d904a56..80e7903 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -542,7 +542,7 @@ static gboolean pairable_timeout_handler(gpointer user_data)
 
 	set_mode(adapter, MGMT_OP_SET_PAIRABLE, 0x00);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void trigger_pairable_timeout(struct btd_adapter *adapter)
@@ -1125,7 +1125,7 @@ static gboolean passive_scanning_timeout(gpointer user_data)
 				adapter->dev_id, sizeof(cp), &cp,
 				passive_scanning_complete, adapter, NULL);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void trigger_passive_scanning(struct btd_adapter *adapter)
@@ -1300,12 +1300,12 @@ static gboolean start_discovery_timeout(gpointer user_data)
 		 */
 		if (adapter->discovery_type == new_type) {
 			if (adapter->discovering)
-				return FALSE;
+				return G_SOURCE_REMOVE;
 
 			adapter->discovering = true;
 			g_dbus_emit_property_changed(dbus_conn, adapter->path,
 					ADAPTER_INTERFACE, "Discovering");
-			return FALSE;
+			return G_SOURCE_REMOVE;
 		}
 
 		/*
@@ -1328,7 +1328,7 @@ static gboolean start_discovery_timeout(gpointer user_data)
 				adapter->dev_id, sizeof(cp), &cp,
 				start_discovery_complete, adapter, NULL);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void trigger_start_discovery(struct btd_adapter *adapter, guint delay)
@@ -1534,7 +1534,7 @@ static gboolean remove_temp_devices(gpointer user_data)
 			adapter_remove_device(adapter, dev);
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void discovery_destroy(void *user_data)
@@ -2381,7 +2381,7 @@ static gboolean load_ltks_timeout(gpointer user_data)
 	mgmt_cancel(adapter->mgmt, adapter->load_ltks_id);
 	adapter->load_ltks_id = 0;
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void load_ltks_complete(uint8_t status, uint16_t length,
@@ -4006,7 +4006,7 @@ static gboolean confirm_name_timeout(gpointer user_data)
 	mgmt_cancel(adapter->mgmt, adapter->confirm_name_id);
 	adapter->confirm_name_id = 0;
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void confirm_name_complete(uint8_t status, uint16_t length,
@@ -4412,7 +4412,7 @@ next:
 
 	dbus_error_free(&err);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static int adapter_authorize(struct btd_adapter *adapter, const bdaddr_t *dst,
@@ -5029,7 +5029,7 @@ static gboolean pair_device_timeout(gpointer user_data)
 
 	adapter_cancel_bonding(adapter, &data->bdaddr, data->addr_type);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void pair_device_complete(uint8_t status, uint16_t length,
diff --git a/src/device.c b/src/device.c
index 77f2322..60fef83 100644
--- a/src/device.c
+++ b/src/device.c
@@ -364,7 +364,7 @@ static gboolean store_device_info_cb(gpointer user_data)
 	g_key_file_free(key_file);
 	g_free(uuids);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static bool device_address_is_private(struct btd_device *dev)
@@ -966,7 +966,7 @@ static gboolean do_disconnect(gpointer user_data)
 	btd_adapter_disconnect_device(device->adapter, &device->bdaddr,
 							device->bdaddr_type);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 int device_block(struct btd_device *device, gboolean update_only)
@@ -3670,7 +3670,7 @@ static gboolean start_discovery(gpointer user_data)
 
 	device->discov_timer = 0;
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 void device_set_paired(struct btd_device *device, gboolean value)
@@ -3784,7 +3784,7 @@ static gboolean svc_idle_cb(gpointer user_data)
 
 	g_free(cb);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 unsigned int device_wait_for_svc_complete(struct btd_device *dev,
@@ -3857,7 +3857,7 @@ static gboolean device_bonding_retry(gpointer data)
 	int err;
 
 	if (!bonding)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	DBG("retrying bonding");
 	bonding->retry_timer = 0;
@@ -3878,7 +3878,7 @@ static gboolean device_bonding_retry(gpointer data)
 	if (err < 0)
 		device_bonding_complete(device, bonding->status);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 int device_bonding_attempt_retry(struct btd_device *device)
@@ -4371,13 +4371,13 @@ static gboolean notify_attios(gpointer user_data)
 	struct btd_device *device = user_data;
 
 	if (device->attrib == NULL)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	g_slist_foreach(device->attios_offline, attio_connected, device->attrib);
 	device->attios = g_slist_concat(device->attios, device->attios_offline);
 	device->attios_offline = NULL;
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 guint btd_device_add_attio_callback(struct btd_device *device,
diff --git a/src/main.c b/src/main.c
index 91d90b4..d88b1d5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -298,7 +298,7 @@ void btd_exit(void)
 static gboolean quit_eventloop(gpointer user_data)
 {
 	btd_exit();
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
@@ -446,7 +446,7 @@ static gboolean watchdog_callback(gpointer user_data)
 {
 	sd_notify(0, "WATCHDOG=1");
 
-	return TRUE;
+	return G_SOURCE_CONTINUE;
 }
 
 static gboolean parse_debug(const char *key, const char *value,
diff --git a/src/sdp-client.c b/src/sdp-client.c
index 51f3048..35e2bfd 100644
--- a/src/sdp-client.c
+++ b/src/sdp-client.c
@@ -59,7 +59,7 @@ static gboolean cached_session_expired(gpointer user_data)
 
 	g_free(cached);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static sdp_session_t *get_cached_sdp_session(const bdaddr_t *src, const bdaddr_t *dst)
diff --git a/src/shared/hciemu.c b/src/shared/hciemu.c
index 0ea191f..5cae951 100644
--- a/src/shared/hciemu.c
+++ b/src/shared/hciemu.c
@@ -284,7 +284,7 @@ static gboolean start_stack(gpointer user_data)
 
 	bthost_start(hciemu->host_stack);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 struct hciemu *hciemu_new(enum hciemu_type type)
diff --git a/src/shared/tester.c b/src/shared/tester.c
index f3edd74..24d5bb9 100644
--- a/src/shared/tester.c
+++ b/src/shared/tester.c
@@ -311,7 +311,7 @@ static gboolean teardown_callback(gpointer user_data)
 	print_progress(test->name, COLOR_MAGENTA, "teardown");
 	test->teardown_func(test->test_data);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean test_timeout(gpointer user_data)
@@ -321,14 +321,14 @@ static gboolean test_timeout(gpointer user_data)
 	test->timeout_id = 0;
 
 	if (!test_current)
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	test->result = TEST_RESULT_TIMED_OUT;
 	print_progress(test->name, COLOR_RED, "test timed out");
 
 	g_idle_add(teardown_callback, test);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void next_test_case(void)
@@ -372,7 +372,7 @@ static gboolean setup_callback(gpointer user_data)
 	print_progress(test->name, COLOR_BLUE, "setup");
 	test->setup_func(test->test_data);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean run_callback(gpointer user_data)
@@ -384,7 +384,7 @@ static gboolean run_callback(gpointer user_data)
 	print_progress(test->name, COLOR_BLACK, "run");
 	test->test_func(test->test_data);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean done_callback(gpointer user_data)
@@ -396,7 +396,7 @@ static gboolean done_callback(gpointer user_data)
 	print_progress(test->name, COLOR_BLACK, "done");
 	next_test_case();
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 void tester_pre_setup_complete(void)
@@ -585,7 +585,7 @@ static gboolean start_tester(gpointer user_data)
 
 	next_test_case();
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 struct wait_data {
@@ -605,7 +605,7 @@ static gboolean wait_callback(gpointer user_data)
 	if (wait->seconds > 0) {
 		print_progress(test->name, COLOR_BLACK, "%u seconds left",
 								wait->seconds);
-		return TRUE;
+		return G_SOURCE_CONTINUE;
 	}
 
 	print_progress(test->name, COLOR_BLACK, "waiting done");
@@ -614,7 +614,7 @@ static gboolean wait_callback(gpointer user_data)
 
 	g_free(wait);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 void tester_wait(unsigned int seconds, tester_wait_func_t func,
diff --git a/tools/btiotest.c b/tools/btiotest.c
index a77eba1..562de58 100644
--- a/tools/btiotest.c
+++ b/tools/btiotest.c
@@ -96,7 +96,7 @@ static gboolean disconn_timeout(gpointer user_data)
 
 	g_io_channel_shutdown(data->io, TRUE, NULL);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void update_sec_level(struct io_data *data)
@@ -199,7 +199,7 @@ static gboolean confirm_timeout(gpointer user_data)
 	if (data->reject >= 0) {
 		printf("Rejecting connection\n");
 		g_io_channel_shutdown(data->io, TRUE, NULL);
-		return FALSE;
+		return G_SOURCE_REMOVE;
 	}
 
 	printf("Accepting connection\n");
@@ -215,7 +215,7 @@ static gboolean confirm_timeout(gpointer user_data)
 		io_data_unref(data);
 	}
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void confirm_cb(GIOChannel *io, gpointer user_data)
diff --git a/unit/test-gdbus-client.c b/unit/test-gdbus-client.c
index 685729a..6353b59 100644
--- a/unit/test-gdbus-client.c
+++ b/unit/test-gdbus-client.c
@@ -715,7 +715,7 @@ static gboolean timeout_test(gpointer user_data)
 
 	g_assert_not_reached();
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gboolean emit_string_change(void *user_data)
@@ -730,7 +730,7 @@ static gboolean emit_string_change(void *user_data)
 	context->timeout_source = g_timeout_add_seconds(2, timeout_test,
 								context);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void proxy_string_changed(GDBusProxy *proxy, void *user_data)
diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index ef05047..171e663 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -464,7 +464,7 @@ static gboolean cancel_transfer(gpointer user_data)
 	if (d->id > 0)
 		g_obex_cancel_transfer(d->id, transfer_complete, user_data);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static gssize abort_data(void *buf, gsize len, gpointer user_data)
diff --git a/unit/test-gobex.c b/unit/test-gobex.c
index 66307c2..cd51009 100644
--- a/unit/test-gobex.c
+++ b/unit/test-gobex.c
@@ -92,13 +92,13 @@ static gboolean timeout(gpointer user_data)
 	GError **err = user_data;
 
 	if (!g_main_loop_is_running(mainloop))
-		return FALSE;
+		return G_SOURCE_REMOVE;
 
 	g_set_error(err, TEST_ERROR, TEST_ERROR_TIMEOUT, "Timed out");
 
 	g_main_loop_quit(mainloop);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void connect_rsp(GObex *obex, GError *err, GObexPacket *rsp,
diff --git a/unit/test-sdp.c b/unit/test-sdp.c
index 6d699e2..03046d7 100644
--- a/unit/test-sdp.c
+++ b/unit/test-sdp.c
@@ -209,7 +209,7 @@ static gboolean send_pdu(gpointer user_data)
 
 	g_assert(len == pdu_len);
 
-	return FALSE;
+	return G_SOURCE_REMOVE;
 }
 
 static void context_increment(struct context *context)
-- 
1.8.4.2



^ permalink raw reply related

* [PATCH 1/3] gdbus: Don't try to remove removed sources
From: Bastien Nocera @ 2013-11-09 17:02 UTC (permalink / raw)
  To: linux-bluetooth


When we return FALSE from idle handlers, the source is removed.
This will be causing warnings in glib 2.40.

See https://bugzilla.gnome.org/show_bug.cgi?id=710724
---
 gdbus/object.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gdbus/object.c b/gdbus/object.c
index 268fed5..b248cbb 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1006,6 +1006,8 @@ static gboolean process_changes(gpointer user_data)
 	if (data->removed != NULL)
 		emit_interfaces_removed(data);
 
+	data->process_id = 0;
+
 	return FALSE;
 }
 
@@ -1019,6 +1021,7 @@ static void generic_unregister(DBusConnection *connection, void *user_data)
 
 	if (data->process_id > 0) {
 		g_source_remove(data->process_id);
+		data->process_id = 0;
 		process_changes(data);
 	}
 
-- 
1.8.4.2



^ permalink raw reply related

* obexd broken for absolute paths
From: Bastien Nocera @ 2013-11-08 19:21 UTC (permalink / raw)
  To: linux-bluetooth

Heya,

I was trying to test gnome-user-share's Bluetooth support for BlueZ 5,
and was quite surprised it didn't work one bit, with transfers failing
as soon as they were created.

I made this simple change to test/simple-obex-agent so you could
replicate the failure. Obviously, change the download path to exist on
your system:
-               return properties['Name']
+               return ("%s/%s" % ("/home/hadess/Downloads/", properties['Name']))

This will see OBEX Push transfers fail as soon as accepted.

I must also mention the dreadful code in agent_reply() in obexd/src/manager.c:
                const char *slash = strrchr(name, '/');
                DBG("Agent replied with %s", name);
                if (!slash) {
                        agent->new_name = g_strdup(name);
                        agent->new_folder = NULL;
                } else {
                        agent->new_name = g_strdup(slash + 1); 
                        agent->new_folder = g_strndup(name, slash - name);
                }

Please use g_path_get_basename() and g_path_get_dirname(). This is even
a security issue because I could pass relative paths and expect some
system file to get overwritten.

Cheers


^ permalink raw reply

* How do you do OBEX testing?
From: Bastien Nocera @ 2013-11-08 16:11 UTC (permalink / raw)
  To: linux-bluetooth

Heya,

I've been testing and fixing OBEX client and server side bugs for a
while, usually in GNOME, but I recently realised how outdated my testing
techniques were, relying on what would be described as "legacy"
phones[1].

I've asked this question on IRC, but I guess I might not be the only one
that needs to test things like this.

So, what do you use for testing ObexFTP, OBEX Push or related protocols
like PBAP?

- Adding an additional dongle on your computer and assigning it to a VM?
- Using software on a newer smartphone (seems Android has more of those
than the badly rated iOS ones)?
- Another computer? a dumb phone?

I'm looking for something that I could run on a laptop with minimal
additional hardware, so any hints would be welcome.

Cheers

[1]: a Sony Ericsson one that refuses to get out of demo mode because
the SIM slot is broken, and a 10-year candybar Nokia phone that can't
hold charge.


^ permalink raw reply

* [PATCH 3/3] android: Change TODO with explaining comment
From: Lukasz Rymanowski @ 2013-11-08 15:48 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: johan.hedberg, szymon.janc, Lukasz Rymanowski
In-Reply-To: <1383925711-26374-1-git-send-email-lukasz.rymanowski@tieto.com>

---
 android/adapter.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index cd820df..cb25954 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -509,7 +509,10 @@ static void pin_code_request_callback(uint16_t index, uint16_t length,
 
 	DBG("%s type %u secure %u", dst, ev->addr.type, ev->secure);
 
-	/* TODO name and CoD of remote devices should probably be cached */
+	/* It is ok to have empty name and CoD of remote devices here since
+	* those information has been already provided on device_connected event
+	* or during device scaning. Android will use that instead.
+	*/
 	memset(&hal_ev, 0, sizeof(hal_ev));
 	bdaddr2android(&ev->addr.bdaddr, hal_ev.bdaddr);
 
@@ -522,7 +525,10 @@ static void send_ssp_request(const bdaddr_t *addr, uint8_t variant,
 {
 	struct hal_ev_ssp_request ev;
 
-	/* TODO name and CoD of remote devices should probably be cached */
+	/* It is ok to have empty name and CoD of remote devices here since
+	* those information has been already provided on device_connected event
+	* or during device scaning. Android will use that instead.
+	*/
 	memset(&ev, 0, sizeof(ev));
 	bdaddr2android(addr, ev.bdaddr);
 	ev.pairing_variant = variant;
-- 
1.8.4


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox