linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/7] shared/io: Add io_recv
@ 2017-10-24 13:24 Luiz Augusto von Dentz
  2017-10-24 13:24 ` [PATCH BlueZ 2/7] shared: Add initial code for 6LoWPAN Luiz Augusto von Dentz
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2017-10-24 13:24 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds io_recv for reading using different buffer pointed by iovec.
---
 src/shared/io-glib.c | 20 ++++++++++++++++++++
 src/shared/io.h      |  1 +
 2 files changed, 21 insertions(+)

diff --git a/src/shared/io-glib.c b/src/shared/io-glib.c
index 6687a6b28..3ea68ac4e 100644
--- a/src/shared/io-glib.c
+++ b/src/shared/io-glib.c
@@ -280,6 +280,26 @@ ssize_t io_send(struct io *io, const struct iovec *iov, int iovcnt)
 	return ret;
 }
 
+ssize_t io_recv(struct io *io, const struct iovec *iov, int iovcnt)
+{
+	int fd;
+	ssize_t ret;
+
+	if (!io || !io->channel)
+		return -ENOTCONN;
+
+	fd = io_get_fd(io);
+
+	do {
+		ret = readv(fd, iov, iovcnt);
+	} while (ret < 0 && errno == EINTR);
+
+	if (ret < 0)
+		return -errno;
+
+	return ret;
+}
+
 bool io_shutdown(struct io *io)
 {
 	if (!io || !io->channel)
diff --git a/src/shared/io.h b/src/shared/io.h
index 8bc1111d0..14f0034cf 100644
--- a/src/shared/io.h
+++ b/src/shared/io.h
@@ -35,6 +35,7 @@ int io_get_fd(struct io *io);
 bool io_set_close_on_destroy(struct io *io, bool do_close);
 
 ssize_t io_send(struct io *io, const struct iovec *iov, int iovcnt);
+ssize_t io_recv(struct io *io, const struct iovec *iov, int iovcnt);
 bool io_shutdown(struct io *io);
 
 typedef bool (*io_callback_func_t)(struct io *io, void *user_data);
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-10-24 13:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-24 13:24 [PATCH BlueZ 1/7] shared/io: Add io_recv Luiz Augusto von Dentz
2017-10-24 13:24 ` [PATCH BlueZ 2/7] shared: Add initial code for 6LoWPAN Luiz Augusto von Dentz
2017-10-24 13:24 ` [PATCH BlueZ 3/7] unit: Add initial test for bt_6lo Luiz Augusto von Dentz
2017-10-24 13:24 ` [PATCH BlueZ 4/7] uuid: Add IPSP UUID Luiz Augusto von Dentz
2017-10-24 13:24 ` [PATCH BlueZ 5/7] build: Add IPSP plugin Luiz Augusto von Dentz
2017-10-24 13:24 ` [PATCH BlueZ 6/7] ipsp: Connect to IPSP PSM Luiz Augusto von Dentz
2017-10-24 13:24 ` [PATCH BlueZ 7/7] ipsp: Add support for bt_6lo Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).