[07/13] page-xfer: Rework send_psi to use send (and flags)

Submitted by Pavel Emelianov on July 6, 2017, 9:40 a.m.

Details

Message ID d852603e-20d8-5061-d8e4-fb8c26153d00@virtuozzo.com
State Accepted
Series "A set of cleanups for pagemaps/xfers/reads before master merge (resend)"
Headers show

Commit Message

Pavel Emelianov July 6, 2017, 9:40 a.m.
There are cases when we need to specify flags with which
to send the ps_iov, so tune-up the send_psi for that and
use where needed.

Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/page-xfer.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index d2745e2..e2c4e10 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -84,16 +84,21 @@  static inline u32 decode_ps_flags(u32 cmd)
 	return cmd >> PS_CMD_BITS;
 }
 
-static inline int send_psi(int sk, struct page_server_iov *pi)
+static inline int send_psi_flags(int sk, struct page_server_iov *pi, int flags)
 {
-	if (write(sk, pi, sizeof(*pi)) != sizeof(*pi)) {
-		pr_perror("Can't write PSI %d to server", pi->cmd);
+	if (send(sk, pi, sizeof(*pi), flags) != sizeof(*pi)) {
+		pr_perror("Can't send PSI %d to server", pi->cmd);
 		return -1;
 	}
 
 	return 0;
 }
 
+static inline int send_psi(int sk, struct page_server_iov *pi)
+{
+	return send_psi_flags(sk, pi, 0);
+}
+
 /* page-server xfer */
 static int write_pages_to_server(struct page_xfer *xfer,
 		int p, unsigned long len)
@@ -1161,11 +1166,9 @@  int request_remote_pages(int pid, unsigned long addr, int nr_pages)
 		.dst_id		= pid,
 	};
 
-	/* We cannot use send_psi here because we have to use MSG_DONTWAIT */
-	if (send(page_server_sk, &pi, sizeof(pi), MSG_DONTWAIT) != sizeof(pi)) {
-		pr_perror("Can't write PSI to server");
+	/* XXX: why MSG_DONTWAIT here? */
+	if (send_psi_flags(page_server_sk, &pi, MSG_DONTWAIT))
 		return -1;
-	}
 
 	tcp_nodelay(page_server_sk, true);
 	return 0;