[CRIU] [PATCH 5/5] rpc: add request/response id

Ruslan Kuprieiev kupruser at gmail.com
Tue Dec 3 08:20:39 PST 2013


This will help to match request with response if requests were sent asynchronously.

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 cr-service.c       | 9 +++++++++
 protobuf/rpc.proto | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/cr-service.c b/cr-service.c
index ce9b7b5..ff7b6b7 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -22,6 +22,9 @@
 
 unsigned int service_sk_ino = -1;
 
+static bool has_msg_id;
+static int msg_id;
+
 static int recv_criu_msg(int socket_fd, CriuReq **msg)
 {
 	unsigned char buf[MAX_MSG_SIZE];
@@ -42,6 +45,9 @@ static int recv_criu_msg(int socket_fd, CriuReq **msg)
 		return -1;
 	}
 
+	has_msg_id	= (*msg)->has_id;
+	msg_id		= (*msg)->id;
+
 	return 1;
 }
 
@@ -50,6 +56,9 @@ static int send_criu_msg(int socket_fd, CriuResp *msg)
 	unsigned char buf[MAX_MSG_SIZE];
 	int len;
 
+	msg->has_id	= has_msg_id;
+	msg->id		= msg_id;
+
 	len = criu_resp__get_packed_size(msg);
 
 	if (criu_resp__pack(msg, buf) != len) {
diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
index c2a37b7..ca9fb67 100644
--- a/protobuf/rpc.proto
+++ b/protobuf/rpc.proto
@@ -44,6 +44,7 @@ message criu_req {
 
 	optional criu_opts opts	= 2;
 	optional criu_ctrl ctrl = 3;
+	optional int32 id	= 4;
 }
 
 /*
@@ -57,4 +58,5 @@ message criu_resp {
 
 	optional criu_dump_resp	dump	= 3;
 	optional criu_restore_resp restore = 4;
+	optional int32 id		= 5;
 }
-- 
1.8.1.2



More information about the CRIU mailing list