@@ -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)
@@ -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);
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(+)