avdtp: Fix setting disconnect timer when there is no local endpoints
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 16 Feb 2021 22:02:10 +0000 (14:02 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:34 +0000 (19:08 +0530)
If there are not local endpoints left there is no point in starting
the disconnect timer as without any endpoint it is not possible to
configure streams anymore so the code should proceed to disconnect
immediately.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/audio/avdtp.c

index fcf1eb0..5f8ae66 100644 (file)
@@ -1668,7 +1668,13 @@ void avdtp_unref(struct avdtp *session)
                else
                        set_disconnect_timer(session);
 #else
-               set_disconnect_timer(session);
+               /* Only set disconnect timer if there are local endpoints
+                * otherwise disconnect immediately.
+                */
+               if (queue_isempty(session->lseps))
+                       connection_lost(session, ECONNRESET);
+               else
+                       set_disconnect_timer(session);
 #endif
                break;
        case AVDTP_SESSION_STATE_CONNECTING: