Diff between 3294c42c9677b185f22f625d8f25aac30a9cb34d and ed0def339ccad7b69278ab613f9fa058d288101c

Changed Files

File Additions Deletions Status
btio/btio.c +31 -0 modified
btio/btio.h +4 -0 modified

Full Patch

diff --git a/btio/btio.c b/btio/btio.c
index 8d99590..c6d056b 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 642af2e..3169beb 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, ...);