linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel Örstadius" <daniel.orstadius@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] spurious disconnection attempt
Date: Thu, 17 Dec 2009 15:44:45 +0200	[thread overview]
Message-ID: <eb7933e20912170544p2d07fc0endc0c50026e42f8c1@mail.gmail.com> (raw)

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

This sequence can happen when disconnecting the MOTOROKR T505

2009-11-27 12:05:30.636932 > ACL data: handle 11 flags 0x02 dlen 12
    L2CAP(s): Disconn req: dcid 0x0040 scid 0x0048
2009-11-27 12:05:30.637054 < ACL data: handle 11 flags 0x02 dlen 12
    L2CAP(s): Disconn rsp: dcid 0x0040 scid 0x0048
2009-11-27 12:05:30.822540 > HCI Event: Number of Completed Packets
(0x13) plen 5
    handle 11 packets 1
2009-11-27 12:05:30.985656 > HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 11 reason 0x13
    Reason: Remote User Terminated Connection
2009-11-27 12:05:32.655273 < HCI Command: Disconnect (0x01|0x0006) plen 3
    handle 0 reason 0x13
    Reason: Remote User Terminated Connection
2009-11-27 12:05:32.661621 > HCI Event: Command Status (0x0f) plen 4
    Disconnect (0x01|0x0006) status 0x12 ncmd 1
    Error: Invalid HCI Command Parameters

A similar situation (trying to disconnect handle 0) can occur by
increasing the timeout value DISCONNECT_TIMER in src/device.c (default
is 2).

The problem seems to be that bluetoothd still calls
src/device.c:do_disconnect even though the link has been disconnected.
Attaching a patch proposal for function device_remove_connection to
try to avoid this. The function looks to be called only when there is
no longer an hci connection to the remote.

/Daniel

[-- Attachment #2: 0001-adding-removal-of-disconnect-timer-to-avoid-spurious.patch --]
[-- Type: text/x-patch, Size: 781 bytes --]

From 15da4dc5ae66235f7274008938ed0a21412634d3 Mon Sep 17 00:00:00 2001
From: Daniel Orstadius <daniel.orstadius@gmail.com>
Date: Thu, 17 Dec 2009 15:29:51 +0200
Subject: [PATCH] adding removal of disconnect timer to avoid spurious disconnection attempt

---
 src/device.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/device.c b/src/device.c
index 17e4ea1..513a813 100644
--- a/src/device.c
+++ b/src/device.c
@@ -765,6 +765,11 @@ void device_remove_connection(struct btd_device *device, DBusConnection *conn,
 
 	device->handle = 0;
 
+	if (device->disconn_timer > 0) {
+		g_source_remove(device->disconn_timer);
+		device->disconn_timer = 0;
+	}
+
 	while (device->disconnects) {
 		DBusMessage *msg = device->disconnects->data;
 
-- 
1.6.0.4


             reply	other threads:[~2009-12-17 13:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-17 13:44 Daniel Örstadius [this message]
2009-12-17 14:07 ` [PATCH] spurious disconnection attempt 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=eb7933e20912170544p2d07fc0endc0c50026e42f8c1@mail.gmail.com \
    --to=daniel.orstadius@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;
as well as URLs for NNTP newsgroup(s).