Diff between b06af6d8aafddf56837e0d40a7dfc0c4df28922a and 626f5678d6196916605070dc715963ec8c9355eb

Changed Files

File Additions Deletions Status
src/shared/io-glib.c +20 -0 modified
src/shared/io-mainloop.c +17 -0 modified
src/shared/io.h +2 -0 modified

Full Patch

diff --git a/src/shared/io-glib.c b/src/shared/io-glib.c
index 882ebd6..a2ada66 100644
--- a/src/shared/io-glib.c
+++ b/src/shared/io-glib.c
@@ -326,6 +326,26 @@ done:
 	return true;
 }
 
+ssize_t io_send(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 = writev(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-mainloop.c b/src/shared/io-mainloop.c
index b7e0f5f..7f80d8f 100644
--- a/src/shared/io-mainloop.c
+++ b/src/shared/io-mainloop.c
@@ -301,6 +301,23 @@ bool io_set_disconnect_handler(struct io *io, io_callback_func_t callback,
 	return true;
 }
 
+ssize_t io_send(struct io *io, const struct iovec *iov, int iovcnt)
+{
+	ssize_t ret;
+
+	if (!io || io->fd < 0)
+		return -ENOTCONN;
+
+	do {
+		ret = writev(io->fd, iov, iovcnt);
+	} while (ret < 0 && errno == EINTR);
+
+	if (ret < 0)
+		return -errno;
+
+	return ret;
+}
+
 bool io_shutdown(struct io *io)
 {
 	if (!io || io->fd < 0)
diff --git a/src/shared/io.h b/src/shared/io.h
index 8897964..8bc1111 100644
--- a/src/shared/io.h
+++ b/src/shared/io.h
@@ -22,6 +22,7 @@
  */
 
 #include <stdbool.h>
+#include <sys/uio.h>
 
 typedef void (*io_destroy_func_t)(void *data);
 
@@ -33,6 +34,7 @@ void io_destroy(struct io *io);
 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);
 bool io_shutdown(struct io *io);
 
 typedef bool (*io_callback_func_t)(struct io *io, void *user_data);