* [PATCH BlueZ] avdtp: Fix always destroying session immediatelly
@ 2019-01-21 11:57 Luiz Augusto von Dentz
2019-01-23 11:23 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2019-01-21 11:57 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In case the remote device sent a close/abort the session shall not be
free immediatelly as the remote may want to reconfigure the stream.
---
profiles/audio/avdtp.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 4f964feb5..f4c9a2ed8 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -412,6 +412,7 @@ struct avdtp {
struct pending_req *req;
guint dc_timer;
+ int dc_timeout;
/* Attempt stream setup instead of disconnecting */
gboolean stream_setup;
@@ -1152,10 +1153,12 @@ static void set_disconnect_timer(struct avdtp *session)
if (session->dc_timer)
remove_disconnect_timer(session);
- if (!session->stream_setup && !session->streams)
+ DBG("timeout %d", session->dc_timeout);
+
+ if (!session->dc_timeout)
session->dc_timer = g_idle_add(disconnect_timeout, session);
else
- session->dc_timer = g_timeout_add_seconds(DISCONNECT_TIMEOUT,
+ session->dc_timer = g_timeout_add_seconds(session->dc_timeout,
disconnect_timeout,
session);
}
@@ -1797,6 +1800,8 @@ static gboolean avdtp_close_cmd(struct avdtp *session, uint8_t transaction,
avdtp_sep_set_state(session, sep, AVDTP_STATE_CLOSING);
+ session->dc_timeout = DISCONNECT_TIMEOUT;
+
if (!avdtp_send(session, transaction, AVDTP_MSG_TYPE_ACCEPT,
AVDTP_CLOSE, NULL, 0))
return FALSE;
@@ -1893,8 +1898,10 @@ static gboolean avdtp_abort_cmd(struct avdtp *session, uint8_t transaction,
ret = avdtp_send(session, transaction, AVDTP_MSG_TYPE_ACCEPT,
AVDTP_ABORT, NULL, 0);
- if (ret)
+ if (ret) {
avdtp_sep_set_state(session, sep, AVDTP_STATE_ABORTING);
+ session->dc_timeout = DISCONNECT_TIMEOUT;
+ }
return ret;
}
@@ -2377,6 +2384,8 @@ struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device,
* with respect to the disconnect timer */
session->stream_setup = TRUE;
+ session->dc_timeout = DISCONNECT_TIMEOUT;
+
avdtp_connect_cb(chan, NULL, session);
return session;
@@ -3512,8 +3521,10 @@ int avdtp_close(struct avdtp *session, struct avdtp_stream *stream,
ret = send_request(session, FALSE, stream, AVDTP_CLOSE,
&req, sizeof(req));
- if (ret == 0)
+ if (ret == 0) {
stream->close_int = TRUE;
+ session->dc_timeout = 0;
+ }
return ret;
}
@@ -3561,8 +3572,10 @@ int avdtp_abort(struct avdtp *session, struct avdtp_stream *stream)
ret = send_request(session, TRUE, stream, AVDTP_ABORT,
&req, sizeof(req));
- if (ret == 0)
+ if (ret == 0) {
stream->abort_int = TRUE;
+ session->dc_timeout = 0;
+ }
return ret;
}
--
2.17.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH BlueZ] avdtp: Fix always destroying session immediatelly
2019-01-21 11:57 [PATCH BlueZ] avdtp: Fix always destroying session immediatelly Luiz Augusto von Dentz
@ 2019-01-23 11:23 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2019-01-23 11:23 UTC (permalink / raw)
To: linux-bluetooth
Hi,
On Mon, Jan 21, 2019 at 1:57 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> In case the remote device sent a close/abort the session shall not be
> free immediatelly as the remote may want to reconfigure the stream.
> ---
> profiles/audio/avdtp.c | 23 ++++++++++++++++++-----
> 1 file changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
> index 4f964feb5..f4c9a2ed8 100644
> --- a/profiles/audio/avdtp.c
> +++ b/profiles/audio/avdtp.c
> @@ -412,6 +412,7 @@ struct avdtp {
> struct pending_req *req;
>
> guint dc_timer;
> + int dc_timeout;
>
> /* Attempt stream setup instead of disconnecting */
> gboolean stream_setup;
> @@ -1152,10 +1153,12 @@ static void set_disconnect_timer(struct avdtp *session)
> if (session->dc_timer)
> remove_disconnect_timer(session);
>
> - if (!session->stream_setup && !session->streams)
> + DBG("timeout %d", session->dc_timeout);
> +
> + if (!session->dc_timeout)
> session->dc_timer = g_idle_add(disconnect_timeout, session);
> else
> - session->dc_timer = g_timeout_add_seconds(DISCONNECT_TIMEOUT,
> + session->dc_timer = g_timeout_add_seconds(session->dc_timeout,
> disconnect_timeout,
> session);
> }
> @@ -1797,6 +1800,8 @@ static gboolean avdtp_close_cmd(struct avdtp *session, uint8_t transaction,
>
> avdtp_sep_set_state(session, sep, AVDTP_STATE_CLOSING);
>
> + session->dc_timeout = DISCONNECT_TIMEOUT;
> +
> if (!avdtp_send(session, transaction, AVDTP_MSG_TYPE_ACCEPT,
> AVDTP_CLOSE, NULL, 0))
> return FALSE;
> @@ -1893,8 +1898,10 @@ static gboolean avdtp_abort_cmd(struct avdtp *session, uint8_t transaction,
>
> ret = avdtp_send(session, transaction, AVDTP_MSG_TYPE_ACCEPT,
> AVDTP_ABORT, NULL, 0);
> - if (ret)
> + if (ret) {
> avdtp_sep_set_state(session, sep, AVDTP_STATE_ABORTING);
> + session->dc_timeout = DISCONNECT_TIMEOUT;
> + }
>
> return ret;
> }
> @@ -2377,6 +2384,8 @@ struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device,
> * with respect to the disconnect timer */
> session->stream_setup = TRUE;
>
> + session->dc_timeout = DISCONNECT_TIMEOUT;
> +
> avdtp_connect_cb(chan, NULL, session);
>
> return session;
> @@ -3512,8 +3521,10 @@ int avdtp_close(struct avdtp *session, struct avdtp_stream *stream,
>
> ret = send_request(session, FALSE, stream, AVDTP_CLOSE,
> &req, sizeof(req));
> - if (ret == 0)
> + if (ret == 0) {
> stream->close_int = TRUE;
> + session->dc_timeout = 0;
> + }
>
> return ret;
> }
> @@ -3561,8 +3572,10 @@ int avdtp_abort(struct avdtp *session, struct avdtp_stream *stream)
>
> ret = send_request(session, TRUE, stream, AVDTP_ABORT,
> &req, sizeof(req));
> - if (ret == 0)
> + if (ret == 0) {
> stream->abort_int = TRUE;
> + session->dc_timeout = 0;
> + }
>
> return ret;
> }
> --
> 2.17.2
Applied.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-23 11:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-21 11:57 [PATCH BlueZ] avdtp: Fix always destroying session immediatelly Luiz Augusto von Dentz
2019-01-23 11:23 ` Luiz Augusto von Dentz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.