[v4,09/15] sk-unix: Move out interconnected pair setup

Submitted by Kirill Tkhai on June 1, 2016, 4:02 p.m.

Details

Message ID 146479697598.23002.17908657931794765739.stgit@pro
State Rejected
Series "Support for packet's msg_name in receive queue of promiscous DGRAM sockets"
Headers show

Commit Message

Kirill Tkhai June 1, 2016, 4:02 p.m.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/sk-unix.c |   40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 4bda078..758eba6 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -1374,10 +1374,29 @@  struct collect_image_info unix_sk_cinfo = {
 	.flags = COLLECT_SHARED,
 };
 
+static void interconnected_pair(struct unix_sk_info *ui, struct unix_sk_info *peer)
+{
+	struct fdinfo_list_entry *fle, *fle_peer;
+	/*
+	 * Select who will restore the pair. Check is identical to
+	 * the one in pipes.c and makes sure tasks wait for each other
+	 * in pids sorting order (ascending).
+	 */
+	fle = file_master(&ui->d);
+	fle_peer = file_master(&peer->d);
+
+	if (fdinfo_rst_prio(fle, fle_peer)) {
+		ui->flags |= USK_PAIR_MASTER;
+		peer->flags |= USK_PAIR_SLAVE;
+	} else {
+		peer->flags |= USK_PAIR_MASTER;
+		ui->flags |= USK_PAIR_SLAVE;
+	}
+}
+
 static int resolve_unix_peers(void *unused)
 {
 	struct unix_sk_info *ui, *peer;
-	struct fdinfo_list_entry *fle, *fle_peer;
 
 	list_for_each_entry(ui, &unix_sockets, list) {
 		if (ui->peer)
@@ -1402,25 +1421,10 @@  static int resolve_unix_peers(void *unused)
 		if (peer->ue->peer != ui->ue->ino)
 			continue;
 
-		/* socketpair or interconnected sockets */
 		peer->peer = ui;
 
-		/*
-		 * Select who will restore the pair. Check is identical to
-		 * the one in pipes.c and makes sure tasks wait for each other
-		 * in pids sorting order (ascending).
-		 */
-
-		fle = file_master(&ui->d);
-		fle_peer = file_master(&peer->d);
-
-		if (fdinfo_rst_prio(fle, fle_peer)) {
-			ui->flags |= USK_PAIR_MASTER;
-			peer->flags |= USK_PAIR_SLAVE;
-		} else {
-			peer->flags |= USK_PAIR_MASTER;
-			ui->flags |= USK_PAIR_SLAVE;
-		}
+		/* socketpair or interconnected sockets */
+		interconnected_pair(ui, peer);
 	}
 
 	pr_info("Unix sockets:\n");

Comments

Pavel Emelianov June 9, 2016, 1:11 p.m.
Applied