This adds btio support for accepting BIS connections when defer setup is enabled on a Broadcast Receiver socket. --- btio/btio.c | 31 +++++++++++++++++++++++++++++++ btio/btio.h | 4 ++++ 2 files changed, 35 insertions(+) diff --git a/btio/btio.c b/btio/btio.c index 8d9959038..c6d056b89 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -1789,6 +1789,37 @@ gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, gpointer user_data, return TRUE; } +gboolean bt_io_bcast_accept(GIOChannel *io, BtIOConnect connect, + gpointer user_data, GDestroyNotify destroy, + GError * *err) +{ + int sock; + char c; + struct pollfd pfd; + + sock = g_io_channel_unix_get_fd(io); + + memset(&pfd, 0, sizeof(pfd)); + pfd.fd = sock; + pfd.events = POLLOUT; + + if (poll(&pfd, 1, 0) < 0) { + ERROR_FAILED(err, "poll", errno); + return FALSE; + } + + if (!(pfd.revents & POLLOUT)) { + if (read(sock, &c, 1) < 0) { + ERROR_FAILED(err, "read", errno); + return FALSE; + } + } + + server_add(io, connect, NULL, user_data, destroy); + + return TRUE; +} + gboolean bt_io_set(GIOChannel *io, GError **err, BtIOOption opt1, ...) { va_list args; diff --git a/btio/btio.h b/btio/btio.h index 642af2e22..3169bebf3 100644 --- a/btio/btio.h +++ b/btio/btio.h @@ -75,6 +75,10 @@ typedef void (*BtIOConnect)(GIOChannel *io, GError *err, gpointer user_data); gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, gpointer user_data, GDestroyNotify destroy, GError **err); +gboolean bt_io_bcast_accept(GIOChannel *io, BtIOConnect connect, + gpointer user_data, GDestroyNotify destroy, + GError **err); + gboolean bt_io_set(GIOChannel *io, GError **err, BtIOOption opt1, ...); gboolean bt_io_get(GIOChannel *io, GError **err, BtIOOption opt1, ...); -- 2.34.1