2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

files: don't create a transport socket for each file

This is an unix dgram socket which doesn't have an address and
isn't connected to somewhere, so we can use one socket for all processes.

v2: return non-zero code in error cases
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Andrew Vagin 2016-07-29 09:41:00 +03:00 committed by Pavel Emelyanov
parent 3e840917c9
commit e46ba88614
4 changed files with 28 additions and 6 deletions

View File

@ -267,6 +267,10 @@ static int root_prepare_shared(void)
if (ret) if (ret)
goto err; goto err;
ret = open_transport_socket();
if (ret)
goto err;
show_saved_files(); show_saved_files();
err: err:
return ret; return ret;
@ -603,6 +607,8 @@ static int restore_one_alive_task(int pid, CoreEntry *core)
if (prepare_vmas(current, ta)) if (prepare_vmas(current, ta))
return -1; return -1;
close_service_fd(TRANSPORT_FD_OFF);
return sigreturn_restore(pid, ta, args_len, core); return sigreturn_restore(pid, ta, args_len, core);
} }

View File

@ -1000,11 +1000,7 @@ static int serve_out_fd(int pid, int fd, struct file_desc *d)
int sock, ret; int sock, ret;
struct fdinfo_list_entry *fle; struct fdinfo_list_entry *fle;
sock = socket(PF_UNIX, SOCK_DGRAM, 0); sock = get_service_fd(TRANSPORT_FD_OFF);
if (sock < 0) {
pr_perror("Can't create socket");
return -1;
}
pr_info("\t\tCreate fd for %d\n", fd); pr_info("\t\tCreate fd for %d\n", fd);
@ -1022,7 +1018,6 @@ static int serve_out_fd(int pid, int fd, struct file_desc *d)
ret = 0; ret = 0;
out: out:
close(sock);
return ret; return ret;
} }
@ -1672,3 +1667,21 @@ char *external_lookup_by_key(char *key)
} }
return NULL; return NULL;
} }
int open_transport_socket()
{
int sock;
sock = socket(PF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (sock < 0) {
pr_perror("Can't create socket");
return -1;
}
if (install_service_fd(TRANSPORT_FD_OFF, sock) < 0) {
close(sock);
return -1;
}
close(sock);
return 0;
}

View File

@ -201,4 +201,6 @@ extern FdinfoEntry *dup_fdinfo(FdinfoEntry *old, int fd, unsigned flags);
int dup_fle(struct pstree_item *task, struct fdinfo_list_entry *ple, int dup_fle(struct pstree_item *task, struct fdinfo_list_entry *ple,
int fd, unsigned flags); int fd, unsigned flags);
extern int open_transport_socket(void);
#endif /* __CR_FILES_H__ */ #endif /* __CR_FILES_H__ */

View File

@ -19,6 +19,7 @@ enum sfd_type {
CGROUP_YARD, CGROUP_YARD,
USERNSD_SK, /* Socket for usernsd */ USERNSD_SK, /* Socket for usernsd */
NS_FD_OFF, /* Node's net namespace fd */ NS_FD_OFF, /* Node's net namespace fd */
TRANSPORT_FD_OFF, /* to transfer file descriptors */
SERVICE_FD_MAX SERVICE_FD_MAX
}; };