Re: [Bluez-devel] About concurrency sdp_connect

Marcel Holtmann
2006-09-26T21:09:08Z

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

Hi Peter,

> my last attempt to make this work actually failed, but I didn't put much
> energy into it. Feel free to come up with a working version. The path
> how to handle this is clear.

forget whatever I told you to handle this inside L2CAP. It is nearly
impossible to get the locking for this right. I crashed my Quad G5
multiple times today.

So I went back to fix this inside the HCI layer. You can apply the
attached patch on top of 2.6.18-mh3 and it should give you concurrent
connect support for all protocols.

Regards

Marcel

[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 2322 bytes --]

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index df22efc..0ace40b 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -289,6 +289,22 @@ static inline struct hci_conn *hci_conn_
return NULL;
}

+static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev,
+ __u8 type, __u16 state)
+{
+ struct hci_conn_hash *h = &hdev->conn_hash;
+ struct list_head *p;
+ struct hci_conn *c;
+
+ list_for_each(p, &h->list) {
+ c = list_entry(p, struct hci_conn, list);
+ if (c->type == type && c->state == state)
+ return c;
+ }
+ return NULL;
+}
+
+void hci_acl_connect(struct hci_conn *conn);
void hci_acl_disconn(struct hci_conn *conn, __u8 reason);
void hci_add_sco(struct hci_conn *conn, __u16 handle);

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 90e3a28..8d0c7e7 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -51,7 +51,7 @@ #undef BT_DBG
#define BT_DBG(D...)
#endif

-static void hci_acl_connect(struct hci_conn *conn)
+void hci_acl_connect(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;
struct inquiry_entry *ie;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index d5693ef..b1b9f12 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -414,9 +414,12 @@ static inline void hci_cs_create_conn(st

if (status) {
if (conn && conn->state == BT_CONNECT) {
- conn->state = BT_CLOSED;
- hci_proto_connect_cfm(conn, status);
- hci_conn_del(conn);
+ if (status != 0x0c) {
+ conn->state = BT_CLOSED;
+ hci_proto_connect_cfm(conn, status);
+ hci_conn_del(conn);
+ } else
+ conn->state = BT_CONNECT2;
}
} else {
if (!conn) {
@@ -728,7 +731,7 @@ static inline void hci_conn_request_evt(
static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
{
struct hci_ev_conn_complete *ev = (struct hci_ev_conn_complete *) skb->data;
- struct hci_conn *conn;
+ struct hci_conn *conn, *pend;

BT_DBG("%s", hdev->name);

@@ -782,6 +785,10 @@ static inline void hci_conn_complete_evt
}

hci_conn_put(conn);
+
+ pend = hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT2);
+ if (pend)
+ hci_acl_connect(pend);
} else
conn->state = BT_CLOSED;

[-- Attachment #3: Type: text/plain, Size: 348 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]