From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> 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 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html