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.
This commit is contained in:
Luiz Augusto von Dentz 2017-05-04 13:12:59 +02:00 committed by Georg Chini
parent 826bb358cc
commit f44f2996b4

View file

@ -201,14 +201,11 @@ static void hf_audio_agent_transport_release(pa_bluetooth_transport *t) {
pa_assert(card); pa_assert(card);
if (t->state <= PA_BLUETOOTH_TRANSPORT_STATE_IDLE) { if (card->fd < 0) {
pa_log_info("Transport %s already released", t->path); pa_log_info("Transport %s already released", t->path);
return; return;
} }
if (card->fd < 0)
return;
/* shutdown to make sure connection is dropped immediately */ /* shutdown to make sure connection is dropped immediately */
shutdown(card->fd, SHUT_RDWR); shutdown(card->fd, SHUT_RDWR);
close(card->fd); close(card->fd);
@ -546,7 +543,7 @@ static DBusMessage *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage
card->connecting = false; 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_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")); pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.InvalidArguments", "Invalid arguments in method call"));
shutdown(fd, SHUT_RDWR); shutdown(fd, SHUT_RDWR);