[CRIU] [PATCH] sk-packet: Don't open image when not needed

Pavel Emelyanov xemul at virtuozzo.com
Thu Jun 29 20:34:21 MSK 2017


It looks like this call to open_image was left from the
times when we reworked packets sending and collected
them early.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/sk-queue.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/criu/sk-queue.c b/criu/sk-queue.c
index f92d020..28578b4 100644
--- a/criu/sk-queue.c
+++ b/criu/sk-queue.c
@@ -200,17 +200,12 @@ err_brk:
 int restore_sk_queue(int fd, unsigned int peer_id)
 {
 	struct sk_packet *pkt, *tmp;
-	int ret;
-	struct cr_img *img;
+	int ret = -1;
 
 	pr_info("Trying to restore recv queue for %u\n", peer_id);
 
 	if (restore_prepare_socket(fd))
-		return -1;
-
-	img = open_image(CR_FD_SK_QUEUES, O_RSTR);
-	if (!img)
-		return -1;
+		goto out;
 
 	list_for_each_entry_safe(pkt, tmp, &packets_list, list) {
 		SkPacketEntry *entry = pkt->entry;
@@ -233,21 +228,20 @@ int restore_sk_queue(int fd, unsigned int peer_id)
 		xfree(pkt->data);
 		if (ret < 0) {
 			pr_perror("Failed to send packet");
-			goto err;
+			goto out;
 		}
 		if (ret != entry->length) {
 			pr_err("Restored skb trimmed to %d/%d\n",
 			       ret, (unsigned int)entry->length);
-			goto err;
+			ret = -1;
+			goto out;
 		}
 		list_del(&pkt->list);
 		sk_packet_entry__free_unpacked(entry, NULL);
 		xfree(pkt);
 	}
 
-	close_image(img);
-	return 0;
-err:
-	close_image(img);
-	return -1;
+	ret = 0;
+out:
+	return ret;
 }
-- 
2.1.4


More information about the CRIU mailing list