From d13f06193cce07e2ad97070ad32e059d76cac4b7 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 16 Feb 2021 14:02:10 -0800 Subject: [PATCH] avdtp: Fix setting disconnect timer when there is no local endpoints 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. --- profiles/audio/avdtp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index fa72ef66a..9ddcd6464 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -1226,7 +1226,13 @@ void avdtp_unref(struct avdtp *session) switch (session->state) { case AVDTP_SESSION_STATE_CONNECTED: - 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); break; case AVDTP_SESSION_STATE_CONNECTING: connection_lost(session, ECONNABORTED); -- 2.47.3