[CRIU] [PATCH 14/19] unix: Split collect_one_unixsk()

Kirill Tkhai ktkhai at virtuozzo.com
Tue Jan 30 18:42:57 MSK 2018


Extract the functionality, which makes socket memory initialization.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/sk-unix.c |   31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index cc2b347af..f5c825381 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -1621,24 +1621,19 @@ static int post_prepare_unix_sk(struct pprep_head *ph)
 	return 0;
 }
 
-static int collect_one_unixsk(void *o, ProtobufCMessage *base, struct cr_img *i)
+static int init_unix_sk_info(struct unix_sk_info *ui, UnixSkEntry *ue)
 {
-	struct unix_sk_info *ui = o;
-	char *uname, *prefix = "";
-	int ulen;
-
-	ui->ue = pb_msg(base, UnixSkEntry);
-	ui->name_dir = (void *)ui->ue->name_dir;
-
-	if (ui->ue->name.len) {
-		if (ui->ue->name.len > UNIX_PATH_MAX) {
-			pr_err("Bad unix name len %d\n", (int)ui->ue->name.len);
+	ui->ue = ue;
+	if (ue->name.len) {
+		if (ue->name.len > UNIX_PATH_MAX) {
+			pr_err("Bad unix name len %d\n", (int)ue->name.len);
 			return -1;
 		}
 
-		ui->name = (void *)ui->ue->name.data;
+		ui->name = (void *)ue->name.data;
 	} else
 		ui->name = NULL;
+	ui->name_dir = (void *)ue->name_dir;
 
 	ui->queuer = NULL;
 	ui->peer = NULL;
@@ -1650,6 +1645,18 @@ static int collect_one_unixsk(void *o, ProtobufCMessage *base, struct cr_img *i)
 	INIT_LIST_HEAD(&ui->node);
 	INIT_LIST_HEAD(&ui->scm_fles);
 	ui->flags = 0;
+
+	return 0;
+}
+
+static int collect_one_unixsk(void *o, ProtobufCMessage *base, struct cr_img *i)
+{
+	struct unix_sk_info *ui = o;
+	char *uname, *prefix = "";
+	int ulen;
+
+	if (init_unix_sk_info(ui, pb_msg(base, UnixSkEntry)))
+		return -1;
 	fixup_sock_net_ns_id(&ui->ue->ns_id, &ui->ue->has_ns_id);
 
 	uname = ui->name;



More information about the CRIU mailing list