[17/18] skqueue: Use sendmsg() to send data

Submitted by Pavel Emelyanov on July 10, 2017, 9:41 a.m.

Details

Message ID 6f35d6a8-690c-7856-5d1f-5f19ee77eba6@virtuozzo.com
State New
Series "Support descriptors sent over unix sockets"
Headers show

Commit Message

Pavel Emelyanov July 10, 2017, 9:41 a.m.
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/sk-queue.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/sk-queue.c b/criu/sk-queue.c
index 057c0bf..77e203e 100644
--- a/criu/sk-queue.c
+++ b/criu/sk-queue.c
@@ -201,6 +201,13 @@  static int send_one_pkt(int fd, struct sk_packet *pkt)
 {
 	int ret;
 	SkPacketEntry *entry = pkt->entry;
+	struct msghdr mh = {};
+	struct iovec iov;
+
+	mh.msg_iov = &iov;
+	mh.msg_iovlen = 1;
+	iov.iov_base = pkt->data;
+	iov.iov_len = entry->length;
 
 	/*
 	 * Don't try to use sendfile here, because it use sendpage() and
@@ -210,7 +217,7 @@  static int send_one_pkt(int fd, struct sk_packet *pkt)
 	 * boundaries messages should be saved.
 	 */
 
-	ret = write(fd, pkt->data, entry->length);
+	ret = sendmsg(fd, &mh, 0);
 	xfree(pkt->data);
 	if (ret < 0) {
 		pr_perror("Failed to send packet");