What steps will reproduce the problem? 1. Register an L2CAP service from a daemon client 2. Close the client 3. Restart the client
What is the expected output? What do you see instead? New client should be able to register services with the same ID. Instead, they are refused because the old connections persist.
What version of the product are you using? On what operating system? SVN trunk, Linux 3.x.
Patch attached -- adds a function to l2cap.c to unregister all services from a particular connection, which is then called from daemon.c as the client is disconnected.
- l2cap_unreg.patch 2.49KB
Comment #1
Posted on Oct 15, 2014 by Helpful RabbitI totally missed the documentation in linked_list.h that points out you do the bookkeeping to make it safe to remove while iterating. Here is a much neater patch.
- l2cap_unreg_v2.patch 1.43KB
Comment #2
Posted on Oct 15, 2014 by Swift OxHi
Until recently, l2cap & rfcomm had to do the bookkeeping about which client would do what. As this violates the layer structure and is not needed in embedded systems, we moved the book-keeping into daemon.c. Check daemon_disconnect_client() the functions it calls.
Comment #3
Posted on Oct 15, 2014 by Helpful RabbitHi Mathias, thanks for pointing that out. I see the code now, but unfortunately it doesn't seem to work for me.
When daemon_packet_handler receives L2CAP_EVENT_SERVICE_REGISTERED, the connection is NULL, presumably because it's coming from the stack - so it doesn't get tallied against the connection. Does this mean one has to keep track of pending connections somewhere else?
A smaller issue is that the status check is also backwards; it checks for !packet[2], but should be packet[2]. (Are the status codes for RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE the same? If so, the same applies.)
Thanks - James
Comment #4
Posted on Oct 15, 2014 by Swift OxThanks for pointing that out. So, we need to add the connection value to the l2cap_event_service_registered event. Will check tomorrow.
No, it's up to the daemon to close all channels and unregister all services.
Which status check is suspicious? (file & line number?)
Comment #5
Posted on Oct 16, 2014 by Happy KangarooWe fixed this. Thanks for helping out.
Comment #6
Posted on Oct 16, 2014 by Helpful RabbitFound the missing connection parameter. Patch is attached - including the status checks.
- l2cap_unreg_v3.patch 2.22KB
Comment #7
Posted on Oct 16, 2014 by Swift Oxthanks, but we won by 2 minutes :)
Comment #8
Posted on Oct 16, 2014 by Helpful Rabbitthen no, thank you ;)
Status: Fixed
Labels:
Type-Defect
Priority-Medium