Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Bruno <rbruno@gsd.inesc-id.pt>2017-02-11 06:34:41 +0300
committerPavel Emelyanov <xemul@virtuozzo.com>2017-03-06 11:38:35 +0300
commit9469f2c022e5d9afbfd2bdb4811dd9dbb90527de (patch)
treeb3a988551be02a5c3a931eed4c7a69744510a7f0
parent1510b248687f978e614b0bc8c08c0027c729c8a3 (diff)
sk: Pre-read sock packets into buffer
criu/sk-queue.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) In order to prepare for the use of sockets to transfer the image files lseek calls needs to be removed. For sk-queue, we now read the packet data at the same time than the header. This has the disadvantage to consume more memory between the image read and the packets restore, but should hopefully be affordable. Signed-off-by: Rodrigo Bruno <rbruno@gsd.inesc-id.pt> Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
-rw-r--r--criu/sk-queue.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/criu/sk-queue.c b/criu/sk-queue.c
index 7b1da2d9f..f92d020db 100644
--- a/criu/sk-queue.c
+++ b/criu/sk-queue.c
@@ -27,7 +27,7 @@
struct sk_packet {
struct list_head list;
SkPacketEntry *entry;
- off_t img_off;
+ char *data;
};
static LIST_HEAD(packets_list);
@@ -37,14 +37,20 @@ static int collect_one_packet(void *obj, ProtobufCMessage *msg, struct cr_img *i
struct sk_packet *pkt = obj;
pkt->entry = pb_msg(msg, SkPacketEntry);
- pkt->img_off = lseek(img_raw_fd(img), 0, SEEK_CUR);
+
+ pkt->data = xmalloc(pkt->entry->length);
+ if (pkt->data ==NULL)
+ return -1;
+
/*
* NOTE: packet must be added to the tail. Otherwise sequence
* will be broken.
*/
list_add_tail(&pkt->list, &packets_list);
- if (lseek(img_raw_fd(img), pkt->entry->length, SEEK_CUR) < 0) {
- pr_perror("Unable to change an image offset");
+
+ if (read_img_buf(img, pkt->data, pkt->entry->length) != 1) {
+ xfree(pkt->data);
+ pr_perror("Unable to read packet data");
return -1;
}
@@ -208,7 +214,6 @@ int restore_sk_queue(int fd, unsigned int peer_id)
list_for_each_entry_safe(pkt, tmp, &packets_list, list) {
SkPacketEntry *entry = pkt->entry;
- char *buf;
if (entry->id_for != peer_id)
continue;
@@ -224,22 +229,8 @@ int restore_sk_queue(int fd, unsigned int peer_id)
* boundaries messages should be saved.
*/
- buf = xmalloc(entry->length);
- if (buf ==NULL)
- goto err;
-
- if (lseek(img_raw_fd(img), pkt->img_off, SEEK_SET) == -1) {
- pr_perror("lseek() failed");
- xfree(buf);
- goto err;
- }
- if (read_img_buf(img, buf, entry->length) != 1) {
- xfree(buf);
- goto err;
- }
-
- ret = write(fd, buf, entry->length);
- xfree(buf);
+ ret = write(fd, pkt->data, entry->length);
+ xfree(pkt->data);
if (ret < 0) {
pr_perror("Failed to send packet");
goto err;