bluetooth: Fix not handle fd in DEFER_SETUP state
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 23 Aug 2013 09:56:40 +0000 (12:56 +0300)
committerIsmo Puustinen <ismo.puustinen@intel.com>
Wed, 28 May 2014 09:29:42 +0000 (12:29 +0300)
The fd passed over NewConnection is in DEFER_SETUP and need to be read to
be accept otherwise it wont work.

Change-Id: I2f6df033d3c1602064a39bb40a5bbd60e014c8f7

src/modules/bluetooth/hfaudioagent-ofono.c

index ba0acaf..90d1348 100644 (file)
@@ -23,6 +23,8 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
+
 #include <pulsecore/core-util.h>
 #include <pulsecore/dbus-shared.h>
 #include <pulsecore/shared.h>
@@ -518,8 +520,16 @@ static DBusMessage *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage
         pa_log_warn("New audio connection on unknown card %s (fd=%d, codec=%d)", card, fd, codec);
         pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.InvalidArguments", "Unknown card"));
         return r;
-    } else
-        pa_log_debug("New audio connection on card %s (fd=%d, codec=%d)", card, fd, codec);
+    }
+
+    pa_log_debug("New audio connection on card %s (fd=%d, codec=%d)", card, fd, codec);
+
+    /* Do the socket defered setup */
+    if (recv(fd, NULL, 0, 0) < 0) {
+        const char *strerr = strerror(errno);
+        pa_log_warn("Defered setup failed: %d (%s)", errno, strerr);
+        pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.InvalidArguments", strerr));
+    }
 
     hfac->fd = fd;
     hfac->codec = codec;