From f44f2996b4ca3d8dc3b9b8362825aff5a225c221 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 4 May 2017 13:12:59 +0200 Subject: [PATCH] bluetooth: ofono: Fix failing to parse valid NewConnection When suspending due to idle timeout the transport will not change its state, also in case the fd is closed due to POLLERR/POLLHUP events the release shall check if the fd is still set otherwise it will fail to be acquired again. --- src/modules/bluetooth/backend-ofono.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/modules/bluetooth/backend-ofono.c b/src/modules/bluetooth/backend-ofono.c index c8109d9f9..c39c6ce2e 100644 --- a/src/modules/bluetooth/backend-ofono.c +++ b/src/modules/bluetooth/backend-ofono.c @@ -201,14 +201,11 @@ static void hf_audio_agent_transport_release(pa_bluetooth_transport *t) { pa_assert(card); - if (t->state <= PA_BLUETOOTH_TRANSPORT_STATE_IDLE) { + if (card->fd < 0) { pa_log_info("Transport %s already released", t->path); return; } - if (card->fd < 0) - return; - /* shutdown to make sure connection is dropped immediately */ shutdown(card->fd, SHUT_RDWR); close(card->fd); @@ -546,7 +543,7 @@ static DBusMessage *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage card->connecting = false; - if (!card || codec != HFP_AUDIO_CODEC_CVSD || card->transport->state == PA_BLUETOOTH_TRANSPORT_STATE_PLAYING) { + if (!card || codec != HFP_AUDIO_CODEC_CVSD || card->fd >= 0) { pa_log_warn("New audio connection invalid arguments (path=%s fd=%d, codec=%d)", path, fd, codec); pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.InvalidArguments", "Invalid arguments in method call")); shutdown(fd, SHUT_RDWR);