[01/12] unix: Link all sockets in unix_sockets list

Submitted by Kirill Tkhai on April 29, 2016, 2:35 p.m.

Details

Message ID 146194050520.9179.14295299835835936319.stgit@pro
State Accepted
Series "Support for packet's msg_name in receive queue of promiscous DGRAM sockets"
Commit 99df229129d8458ffc92fd5fad125b161deaf518
Headers show

Commit Message

Kirill Tkhai April 29, 2016, 2:35 p.m.
List "unix_sockets" is used to link external sockets.
Change this, to link all unix sockets there. To differ
really external sockets in fix_external_unix_sockets(),
we may check for socket's already_dumped value.

This may be useful to traverse over all unix sockets
in a namespace.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/sk-unix.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 1396d76..4ad21af 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -350,11 +350,7 @@  static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
 		 * until all sockets the program owns are processed.
 		 */
 		if (!peer->sd.already_dumped) {
-			if (list_empty(&peer->list)) {
-				show_one_unix("Add a peer", peer);
-				list_add_tail(&peer->list, &unix_sockets);
-			}
-
+			show_one_unix("Add a peer", peer);
 			list_add(&sk->peer_node, &peer->peer_list);
 			sk->fd = dup(lfd);
 			if (sk->fd < 0) {
@@ -447,7 +443,6 @@  static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
 	if (list_empty(&sk->peer_node) && write_unix_entry(sk))
 		return -1;
 
-	list_del_init(&sk->list);
 	sk->sd.already_dumped = 1;
 
 	while (!list_empty(&sk->peer_list)) {
@@ -660,6 +655,7 @@  static int unix_collect_one(const struct unix_diag_msg *m,
 	}
 
 	sk_collect_one(m->udiag_ino, AF_UNIX, &d->sd);
+	list_add_tail(&d->list, &unix_sockets);
 	show_one_unix("Collected", d);
 
 	return 0;
@@ -740,9 +736,10 @@  int fix_external_unix_sockets(void)
 		FownEntry fown = FOWN_ENTRY__INIT;
 		SkOptsEntry skopts = SK_OPTS_ENTRY__INIT;
 
-		show_one_unix("Dumping extern", sk);
+		if (sk->sd.already_dumped)
+			continue;
 
-		BUG_ON(sk->sd.already_dumped);
+		show_one_unix("Dumping extern", sk);
 
 		fd_id_generate_special(NULL, &e.id);
 		e.ino		= sk->sd.ino;