[CRIU] [PATCH 25/28] files: Add fake fle flag and close such fles after restore files
Andrei Vagin
avagin at virtuozzo.com
Tue Jun 6 22:02:12 MSK 2017
On Mon, Jun 05, 2017 at 08:27:07PM +0300, Kirill Tkhai wrote:
> Allow to mark some fles as "fake" and close them, when they are not needed.
>
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
> criu/files.c | 14 ++++++++++++++
> criu/include/files.h | 1 +
> 2 files changed, 15 insertions(+)
>
> diff --git a/criu/files.c b/criu/files.c
> index a2b57ca01..f97b7a0a2 100644
> --- a/criu/files.c
> +++ b/criu/files.c
> @@ -710,6 +710,7 @@ static struct fdinfo_list_entry *alloc_fle(int pid, FdinfoEntry *fe)
> fle->pid = pid;
> fle->fe = fe;
> fle->received = 0;
> + fle->fake = 0;
> fle->stage = FLE_INITIALIZED;
> fle->task = pstree_item_by_virt(pid);
> if (!fle->task) {
> @@ -1199,6 +1200,17 @@ static int open_fdinfos(struct pstree_item *me)
> return ret;
> }
>
> +static void close_fake_fdinfos(struct pstree_item *me)
> +{
> + struct list_head *list = &rsti(me)->fds;
> + struct fdinfo_list_entry *fle;
> +
> + list_for_each_entry(fle, list, ps_list) {
> + if (fle->fake)
> + close(fle->fe->fd);
> + }
Why we can't to close it immediately after sending it to all recipients?
> +}
> +
> static struct inherit_fd *inherit_fd_lookup_fd(int fd, const char *caller);
>
> int close_old_fds(void)
> @@ -1268,6 +1280,8 @@ int prepare_fds(struct pstree_item *me)
> BUG_ON(current->pid->state == TASK_HELPER);
> ret = open_fdinfos(me);
>
> + close_fake_fdinfos(me);
> +
> if (rsti(me)->fdt)
> futex_inc_and_wake(&rsti(me)->fdt->fdt_lock);
> out:
> diff --git a/criu/include/files.h b/criu/include/files.h
> index fd2d20761..fb47eb879 100644
> --- a/criu/include/files.h
> +++ b/criu/include/files.h
> @@ -80,6 +80,7 @@ struct fdinfo_list_entry {
> FdinfoEntry *fe;
> u8 received:1;
> u8 stage:3;
> + u8 fake:1;
> };
>
> /* reports whether fd_a takes prio over fd_b */
>
More information about the CRIU
mailing list