[CRIU] Re: [PATCH cr 03/12] pipe: all pipes are seved in one file

Pavel Emelyanov xemul at parallels.com
Thu Apr 5 07:57:10 EDT 2012


On 04/05/2012 03:47 PM, Andrey Vagin wrote:
> 
> Information about pipe's file structs saved in one global file and
> fdinfo_entry is saved for each descriptor
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  cr-dump.c         |  203 ++++++++++++++++++++++++++---------------------------
>  cr-show.c         |    4 +-
>  include/crtools.h |    4 +-
>  include/image.h   |    5 +-
>  4 files changed, 108 insertions(+), 108 deletions(-)
> 

> +	if (!(p->flags & O_WRONLY) && i == nr_pipes) {
> +		pipes[nr_pipes] = p->id;
> +		nr_pipes++;
> +		if (nr_pipes > PIPES_SIZE) {
> +			pr_err("OOM storing pipe\n");
> +			return -1;
> +		}
> +	} else

> +	pipes = xmalloc(PIPES_SIZE);
> +	if (!pipes)
> +		goto err;
>  

PIPES_SIZE is the number of bytes, but you check for overflow
by comparing number of items with it.

> +	for (i = 0; i < nr_pipes; i++)
> +		if (pipes[i] == p->id)
> +			break;
> +
> +	if (!(p->flags & O_WRONLY) && i == nr_pipes) {

O_o write ends of pipes do not happen to be in this array? What is it for?

> +		pipes[nr_pipes] = p->id;
> +		nr_pipes++;
> +		if (nr_pipes > PIPES_SIZE) {
> +			pr_err("OOM storing pipe\n");
> +			return -1;
> +		}
> +	} else
> +		goto dump;



More information about the CRIU mailing list