All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Hurley <peter@hurleysoftware.com>
To: Marcel Holtmann <marcel@holtmann.org>,
	Scott James Remnant <keybuk@chromium.org>
Cc: linux-bluetooth@vger.kernel.org, Peter Hurley <peter@hurleysoftware.com>
Subject: [PATCH 2/3] bluetooth: rfcomm: Create new session if closing old session
Date: Thu, 13 Mar 2014 12:43:05 -0400	[thread overview]
Message-ID: <1394728986-5096-3-git-send-email-peter@hurleysoftware.com> (raw)
In-Reply-To: <1394728986-5096-1-git-send-email-peter@hurleysoftware.com>

If the rfcomm session has already sent DISC (thus in BT_DISCONN
state), allow dlc opens to create a new session instead of trying
to open a dlc in a closing session (and instead of returning an
error).

Allow multiple rfcomm sessions with the same endpoints as long as
the existing sessions are either in BT_DISCONN or BT_CLOSED states.

Fixes multi-second delays when running rctest -c on one station
and rctest -r on the other.

Reported-by: Scott James Remnant <keybuk@chromium.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 net/bluetooth/rfcomm/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 6aa90c0..292322c 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -695,6 +695,9 @@ static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst)
 		s = list_entry(p, struct rfcomm_session, list);
 		chan = l2cap_pi(s->sock->sk)->chan;
 
+		if (s->state == BT_DISCONN || s->state == BT_CLOSED)
+			continue;
+
 		if ((!bacmp(src, BDADDR_ANY) || !bacmp(&chan->src, src)) &&
 		    !bacmp(&chan->dst, dst))
 			return s;
-- 
1.8.1.2


  parent reply	other threads:[~2014-03-13 16:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-11 21:44 rctest -c "Can't connect: Device or resource busy (16)" Scott James Remnant
2014-03-11 23:03 ` Marcel Holtmann
2014-03-11 23:37   ` Scott James Remnant
2014-03-12  2:14     ` Marcel Holtmann
2014-03-12  3:01       ` Peter Hurley
2014-03-12  3:27         ` Peter Hurley
2014-03-12  4:27         ` Peter Hurley
2014-03-12 17:18         ` Peter Hurley
2014-03-28 17:49           ` Scott James Remnant
2014-03-13 16:43       ` [PATCH 0/3] Fix RFCOMM connect/disconn races Peter Hurley
2014-03-13 16:43         ` [PATCH 1/3] bluetooth: rfcomm: Reply with DM after dlc disconnect Peter Hurley
2014-03-13 16:43         ` Peter Hurley [this message]
2014-03-13 16:43         ` [PATCH 3/3] bluetooth: rfcomm: Defer session teardown after last dlc Peter Hurley
2014-04-02 20:04         ` [PATCH 0/3] Fix RFCOMM connect/disconn races Marcel Holtmann

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=1394728986-5096-3-git-send-email-peter@hurleysoftware.com \
    --to=peter@hurleysoftware.com \
    --cc=keybuk@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.