[15/16] skqueue: Use send() to send data

Submitted by Pavel Emelianov on July 6, 2017, 4:18 p.m.

Details

Message ID 2af5c33e-2d26-39b2-cf0a-0ec60276c4d4@virtuozzo.com
State Accepted
Series "Support descriptors sent over unix sockets"
Commit e10031be08d9605432c4d61b0f169af79c4dd9f2
Headers show

Commit Message

Pavel Emelianov July 6, 2017, 4:18 p.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");