From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 1/7] shared/io: Add io_recv
Date: Tue, 24 Oct 2017 16:24:53 +0300 [thread overview]
Message-ID: <20171024132459.14206-1-luiz.dentz@gmail.com> (raw)
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
next reply other threads:[~2017-10-24 13:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-24 13:24 Luiz Augusto von Dentz [this message]
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
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=20171024132459.14206-1-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/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 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).