"File descriptor in bad state" on sdp_connect()
Subsystems (2)
Hi,
I have a problem with multiple concurrent calls to sdp_connect(). In particular, I have a simple application that search a service on different remote devices: the searches are done concurrently (until 7 in parallel), each from within a different pthread. I have experienced that, with a lot of Bluetooth dongles (example Surecom, D-Link), it occurs an "File descriptor in bad state" error. Debugging the sdp_connect() function I have founded that the error occurs on connect() system call.
Has anyone had a similar problem?
Do you have any suggestion?
Thanks,
Marco Pracucci
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Hi Marco,
Quoted 11 lines · Marco Pracucci
Hi,
I have a problem with multiple concurrent calls to
sdp_connect(). In particular, I have a simple application that search a service on different remote devices: the searches are done concurrently (until 7 in parallel), each from within a different pthread. I have experienced that, with a lot of Bluetooth dongles (example Surecom, D-Link), it occurs an "File descriptor in bad state" error. Debugging thesdp_connect()function I have founded that the error occurs onconnect()system call.
This problem has been discussed here several times for various applications. It is not related to SDP but to the general problem that (all ?) commercial available Bluetooth adaptors do not support multiple (concurrent) connection requests. The only solution is to serialize the connect requests. Until now nobody voluntered to do this in the kernel.
Ciao,
Peter
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Hi Peter,
Quoted 9 lines · Peter Wippich
Quoted 9 lines
I have a problem with multiple concurrent calls to
sdp_connect(). In particular, I have a simple application that search a service on different remote devices: the searches are done concurrently (until 7 in parallel), each from within a different pthread. I have experienced that, with a lot of Bluetooth dongles (example Surecom, D-Link), it occurs an "File descriptor in bad state" error. Debugging thesdp_connect()function I have founded that the error occurs onconnect()system call.
Quoted 5 lines
This problem has been discussed here several times for various applications. It is not related to SDP but to the general problem that (all ?) commercial available Bluetooth adaptors do not support multiple (concurrent) connection requests. The only solution is to serialize the connect requests. Until now nobody voluntered to do this in the kernel.
I'm working on this right now. I think I've found the problems with that Marcel Holtmann's patch. I'm gonna test it a little bit more and then I'll send the patch to the list. :-)
Regards,
-- Ulisses
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Hi,
I have had a similar problem ....I've discovered (with Marcel help) is a problem in l2cap layer.
l2cap kernel module do not handle multiple connect, Marcel send to me a patch I am trying to make to work
but I'm very busy with my job and is not still clear where the patch
hangs the system.
You can found some information searching in old messages....
Ciao
Fabrizio
Marco Pracucci ha scritto:
Quoted 18 lines
Hi,
I have a problem with multiple concurrent calls to
sdp_connect(). In particular, I have a simple application that search a service on different remote devices: the searches are done concurrently (until 7 in parallel), each from within a different pthread. I have experienced that, with a lot of Bluetooth dongles (example Surecom, D-Link), it occurs an "File descriptor in bad state" error. Debugging thesdp_connect()function I have founded that the error occurs onconnect()system call.Has anyone had a similar problem?
Do you have any suggestion?Thanks,
Marco Pracucci
Quoted 12 lines
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Hi Fabrizio,
Quoted 6 lines · Fabrizio Guglielmino
I have had a similar problem ....I've discovered (with Marcel help) is a problem in l2cap layer.
l2cap kernel module do not handle multiple connect, Marcel send to me a patch I am trying to make to work
but I'm very busy with my job and is not still clear where the patch
hangs the system.
We thought we had a deadlock somewhere but it wasn't the case. We had two problems:
- trying to list_del() the same list entry twice leading us to a page fault
- we've forgotten to INIT_LIST_HEAD() our l2cap_conn->list leading us to a NULL pointer dereference
I've done some modifications (and also included some bits from -mh) and it seems to be working. However, I'm hitting a kernel bug at kernel/timer.c inside cascade() from time to time. I haven't found what is causing this yet, but the patch I'm sending is against 2.6.17 and I haven't tested with latest git snapshot so maybe this issue is already fixed upstream (kernel/timer.c:cascade() was changed [1]). Marcel, do you have any idea of what might be happening?
If anyone wants to give this beast a try you're warned that it might lock up your system. FWIW, a quick test can be done using l2test from CVS like:
$ ./l2test -m bd_addr1 bd_addr2 ...
Best regards,
-- Ulisses
include/net/bluetooth/l2cap.h +2 -0
@@ -183,6 +183,8 @@ };struct l2cap_conn { +struct list_head list; +struct hci_conn *hcon;bdaddr_t *dst;
net/bluetooth/l2cap.c +65 -27
169 lines not on this page · raw message
Marcel Holtmann
maintainerHi Ulisses,
Quoted 14 lines
Quoted 6 lines
I have had a similar problem ....I've discovered (with Marcel help) is a problem in l2cap layer.
l2cap kernel module do not handle multiple connect, Marcel send to me a patch I am trying to make to work
but I'm very busy with my job and is not still clear where the patch
hangs the system.We thought we had a deadlock somewhere but it wasn't the case. We had two problems:
- trying to
list_del()the same list entry twice leading us to a page fault
- we've forgotten toINIT_LIST_HEAD()ourl2cap_conn->listleading us
to a NULL pointer dereference
Quoted 6 lines
I've done some modifications (and also included some bits from -mh) and it seems to be working. However, I'm hitting a kernel bug at
kernel/timer.cinsidecascade()from time to time. I haven't found what is causing this yet, but the patch I'm sending is against 2.6.17 and I haven't tested with latest git snapshot so maybe this issue is already fixed upstream (kernel/timer.c:cascade() was changed [1]).
please redo the patch against 2.6.18-rc4 and I will do some additional testing.
Regards
Marcel
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Hi Marcel,
Quoted 9 lines · Marcel Holtmann
Quoted 6 lines
I've done some modifications (and also included some bits from -mh) and it seems to be working. However, I'm hitting a kernel bug at
kernel/timer.cinsidecascade()from time to time. I haven't found what is causing this yet, but the patch I'm sending is against 2.6.17 and I haven't tested with latest git snapshot so maybe this issue is already fixed upstream (kernel/timer.c:cascade() was changed [1]).please redo the patch against 2.6.18-rc4 and I will do some additional testing.
Done. Here is the same patch against 2.6.18-rc4.
Regards,
-- Ulisses
include/net/bluetooth/l2cap.h +2 -0
@@ -183,6 +183,8 @@ };struct l2cap_conn { +struct list_head list; +struct hci_conn *hcon;bdaddr_t *dst;
net/bluetooth/l2cap.c +54 -16
96 lines not on this page · raw message
Marcel Holtmann
maintainerHi Ulisses,
Quoted 11 lines
Quoted 9 lines
Quoted 6 lines
I've done some modifications (and also included some bits from -mh) and it seems to be working. However, I'm hitting a kernel bug at
kernel/timer.cinsidecascade()from time to time. I haven't found what is causing this yet, but the patch I'm sending is against 2.6.17 and I haven't tested with latest git snapshot so maybe this issue is already fixed upstream (kernel/timer.c:cascade() was changed [1]).please redo the patch against 2.6.18-rc4 and I will do some additional testing.
Done. Here is the same patch against 2.6.18-rc4.
I tested this patch on my Quad G5. I don't see any timer issues, but it also doesn't work either.
Regards
Marcel
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Hi Marcel,
Quoted 7 lines · Marcel Holtmann
Quoted 4 lines
Quoted 2 lines
please redo the patch against 2.6.18-rc4 and I will do some additional testing.
Done. Here is the same patch against 2.6.18-rc4.
I tested this patch on my Quad G5. I don't see any timer issues, but it also doesn't work either.
Damn it. You don't have an HCI dump while l2test is running, do you? (or even l2test output, debug messages..). Thanks.
Regards,
-- Ulisses
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel Holtmann
maintainerHi Ulisses,
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
please redo the patch against 2.6.18-rc4 and I will do some additional testing.
Done. Here is the same patch against 2.6.18-rc4.
I tested this patch on my Quad G5. I don't see any timer issues, but it also doesn't work either.
Damn it. You don't have an HCI dump while l2test is running, do you? (or even l2test output, debug messages..). Thanks.
now my machine freezed when I tried to get a hcidump for you. However I remember seeing the Command Disallowed error and after the Connect Complete, I didn't see the additional Create Connection.
Regards
Marcel
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel Holtmann
maintainerHi Ulisses,
Quoted 11 lines
Quoted 6 lines
I have had a similar problem ....I've discovered (with Marcel help) is a problem in l2cap layer.
l2cap kernel module do not handle multiple connect, Marcel send to me a patch I am trying to make to work
but I'm very busy with my job and is not still clear where the patch
hangs the system.We thought we had a deadlock somewhere but it wasn't the case. We had two problems:
- trying to
list_del()the same list entry twice leading us to a page fault
where do we delete the entry twice?
Quoted 2 lines
- we've forgotten to
INIT_LIST_HEAD()ourl2cap_conn->listleading us
to a NULL pointer dereference
This must be another bug, because it is not needed to init the list item itself. You only have to init the list head.
The attached patch should not change any behavior, but keep track of L2CAP connections in creation state. Please test and check the output of dmesg.
Regards
Marcel
include/net/bluetooth/l2cap.h +2 -0
@@ -183,6 +183,8 @@ struct l2cap_chan_list { };struct l2cap_conn { +struct list_head list; +struct hci_conn *hcon;bdaddr_t *dst;
net/bluetooth/l2cap.c +67 -17
116 lines not on this page · raw message
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Hi Marcel,
Quoted 3 lines · Marcel Holtmann
Quoted 1 line
- trying to
list_del()the same list entry twice leading us to a page faultwhere do we delete the entry twice?
On the first version of the patch (the one you sent to the list) there was a list_del() inside l2cap_conn_del(). This list_del() was causing a page fault trying to dereference prev and next pointers that were poisoned because of a previous list_del().
Quoted 5 lines
Quoted 2 lines
- we've forgotten to
INIT_LIST_HEAD()ourl2cap_conn->listleading us
to a NULL pointer dereferenceThis must be another bug, because it is not needed to init the list item itself. You only have to init the list head.
Hmm.. I think you're right as we already declare our list head with LIST_HEAD(). I was seeing a NULL pointer dereference inside list_del(), tough. Weird.
Quoted 3 lines
The attached patch should not change any behavior, but keep track of L2CAP connections in creation state. Please test and check the output of dmesg.
Ok.
-- Ulisses
Hi Marcel,
Quoted 3 lines · Marcel Holtmann
The attached patch should not change any behavior, but keep track of L2CAP connections in creation state. Please test and check the output of dmesg.
Hmm.. actually it changes the behavior a little bit. This part:
default: conn = hcon->l2cap_data; if (!conn) break; spin_lock_bh(&l2cap_conn_lock); list_del(&conn->list); spin_unlock_bh(&l2cap_conn_lock); l2cap_conn_del(hcon, bt_err(status)); break;
should be like the following code. Otherwise we end up not calling l2cap_conn_del() on hcon, right? (or am I missing anything?)
default:
if ((conn = hcon->l2cap_data)) {
spin_lock_bh(&l2cap_conn_lock);
list_del(&conn->list);
spin_unlock_bh(&l2cap_conn_lock);
}
l2cap_conn_del(hcon, bt_err(status));
break;Best regards,
-- Ulisses
Marcel Holtmann
maintainerHi Ulisses,
Quoted 21 lines
Quoted 3 lines
The attached patch should not change any behavior, but keep track of L2CAP connections in creation state. Please test and check the output of dmesg.
Hmm.. actually it changes the behavior a little bit. This part:
default: conn = hcon->l2cap_data; if (!conn) break; spin_lock_bh(&l2cap_conn_lock); list_del(&conn->list); spin_unlock_bh(&l2cap_conn_lock);l2cap_conn_del(hcon, bt_err(status)); break;should be like the following code. Otherwise we end up not calling
l2cap_conn_del()on hcon, right? (or am I missing anything?)
Quoted 8 lines
default:
if ((conn = hcon->l2cap_data)) {
spin_lock_bh(&l2cap_conn_lock);
list_del(&conn->list);
spin_unlock_bh(&l2cap_conn_lock);
}
l2cap_conn_del(hcon, bt_err(status));
break;look into l2cap_conn_del() and check what happens if l2cap_data is NULL. This doesn't change the behavior.
Regards
Marcel
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Quoted 2 lines · Marcel Holtmann
look into
l2cap_conn_del()and check what happens ifl2cap_datais NULL. This doesn't change the behavior.
Doooh. Right. We shouldn't be calling l2cap_conn_del() at all if l2cap_data is NULL so it doesn't change any behavior and we actually save one function call. :-)
Regards,
-- Ulisses
Hi Ulisses,
I have been outside for a few days...and now I'm reading all the mail about sdp_connect problem.
if I find the time I install the patch on a development system so I try to contribute to the final version.
bye
Il giorno 11/ago/06, alle ore 22:09, Ulisses Furquim ha scritto:
Quoted 13 lines · Marcel Holtmann
Quoted 3 lines
look into
l2cap_conn_del()and check what happens ifl2cap_datais NULL.
This doesn't change the behavior.Doooh. Right. We shouldn't be calling
l2cap_conn_del()at all ifl2cap_datais NULL so it doesn't change any behavior and we actually save one function call. :-)Regards,
-- Ulisses
Quoted 15 lines
----------------------------------------------------------------------
---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?
cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel