All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: patrik.flykt@linux.intel.com, linux-wpan@vger.kernel.org
Subject: [RFC 1/7] shared/io: Add io_recv
Date: Fri, 20 Oct 2017 13:22:30 +0300	[thread overview]
Message-ID: <20171020102236.17499-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20171020102236.17499-1-luiz.dentz@gmail.com>

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


  reply	other threads:[~2017-10-20 10:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20 10:22 [RFC 0/7] 6LoWPAN userspace support Luiz Augusto von Dentz
2017-10-20 10:22 ` Luiz Augusto von Dentz [this message]
2017-10-20 10:22 ` [RFC 2/7] shared: Add initial code for 6LoWPAN Luiz Augusto von Dentz
2017-10-20 10:22 ` [RFC 3/7] unit: Add initial test for bt_6lo Luiz Augusto von Dentz
2017-10-20 10:22 ` [RFC 4/7] uuid: Add IPSP UUID Luiz Augusto von Dentz
2017-10-20 10:22 ` [RFC 5/7] build: Add IPSP plugin Luiz Augusto von Dentz
2017-10-20 10:22 ` [RFC 6/7] ipsp: Connect to IPSP PSM Luiz Augusto von Dentz
2017-10-20 10:22 ` [RFC 7/7] ipsp: Add support for bt_6lo Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171020102236.17499-2-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=patrik.flykt@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.