[CRIU] [PATCH v5 09/11] sk-queue: Use sendto() to restore socket queue
Kirill Tkhai
ktkhai at virtuozzo.com
Thu Jun 16 06:54:25 PDT 2016
v5: New. This was split from:
"allow to use several file descriptors to restore a queue"
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/include/sk-queue.h | 7 ++++++-
criu/sk-queue.c | 9 +++++----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/criu/include/sk-queue.h b/criu/include/sk-queue.h
index e3d8dff..a16edc6 100644
--- a/criu/include/sk-queue.h
+++ b/criu/include/sk-queue.h
@@ -16,6 +16,11 @@ extern struct list_head packets_list;
extern struct collect_image_info sk_queues_cinfo;
extern int dump_sk_queue(int sock_fd, int sock_id, u64 (*get_sender)(const char *, int));
-extern int restore_sk_queue(int fd, unsigned int peer_id);
+extern int __restore_sk_queue(int queuer_fd, unsigned int peer_id,
+ struct sockaddr *dst_addr, socklen_t dst_addrlen);
+static inline int restore_sk_queue(int queuer_fd, unsigned int peer_id)
+{
+ return __restore_sk_queue(queuer_fd, peer_id, NULL, 0);
+}
#endif /* __CR_SK_QUEUE_H__ */
diff --git a/criu/sk-queue.c b/criu/sk-queue.c
index 8e6556a..9e9a484 100644
--- a/criu/sk-queue.c
+++ b/criu/sk-queue.c
@@ -188,15 +188,15 @@ int dump_sk_queue(int sock_fd, int sock_id, u64 (*get_sender)(const char *, int)
return ret;
}
-int restore_sk_queue(int fd, unsigned int peer_id)
+int __restore_sk_queue(int queuer_fd, unsigned int peer_id, struct sockaddr *dst_addr, socklen_t dst_addrlen)
{
struct sk_packet *pkt, *tmp;
- int ret;
struct cr_img *img;
+ int fd, ret;
pr_info("Trying to restore recv queue for %u\n", peer_id);
- if (restore_prepare_socket(fd))
+ if (restore_prepare_socket(queuer_fd) < 0)
return -1;
img = open_image(CR_FD_SK_QUEUES, O_RSTR);
@@ -235,7 +235,8 @@ int restore_sk_queue(int fd, unsigned int peer_id)
goto err;
}
- ret = write(fd, buf, entry->length);
+ fd = queuer_fd;
+ ret = sendto(fd, buf, entry->length, 0, dst_addr, dst_addrlen);
xfree(buf);
if (ret < 0) {
pr_perror("Failed to send packet");
More information about the CRIU
mailing list