[CRIU] [PATCH] files: don't create a transport socket for each file ++

Andrei Vagin avagin at virtuozzo.com
Thu Aug 11 13:37:27 PDT 2016


On Wed, Aug 10, 2016 at 07:28:55PM +0300, Pavel Emelyanov wrote:
> The same thing as in e46ba88614 exists in pipes, unix sockets and
> ttys, so let's re-use the service transport fd there as well.
> 
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>

Acked-by: Andrei Vagin <avagin at virtuozzo.com>

Thanks!
> 
> ---
> 
> diff --git a/criu/pipes.c b/criu/pipes.c
> index fa59071..5761847 100644
> --- a/criu/pipes.c
> +++ b/criu/pipes.c
> @@ -301,11 +301,7 @@ static int open_pipe(struct file_desc *d)
>  	if (ret)
>  		return -1;
>  
> -	sock = socket(PF_UNIX, SOCK_DGRAM, 0);
> -	if (sock < 0) {
> -		pr_perror("Can't create socket");
> -		return -1;
> -	}
> +	sock = get_service_fd(TRANSPORT_FD_OFF);
>  
>  	list_for_each_entry(p, &pi->pipe_list, pipe_list) {
>  		struct fdinfo_list_entry *fle;
> @@ -320,8 +316,6 @@ static int open_pipe(struct file_desc *d)
>  		}
>  	}
>  
> -	close(sock);
> -
>  	close(pfd[!(pi->pe->flags & O_WRONLY)]);
>  	tmp = pfd[pi->pe->flags & O_WRONLY];
>  
> diff --git a/criu/sk-unix.c b/criu/sk-unix.c
> index 2bab17f..99f0b08 100644
> --- a/criu/sk-unix.c
> +++ b/criu/sk-unix.c
> @@ -1080,11 +1080,7 @@ static int open_unixsk_pair_master(struct unix_sk_info *ui)
>  	if (shutdown_unix_sk(sk[0], ui))
>  		return -1;
>  
> -	tsk = socket(PF_UNIX, SOCK_DGRAM, 0);
> -	if (tsk < 0) {
> -		pr_perror("Can't make transport socket");
> -		return -1;
> -	}
> +	tsk = get_service_fd(TRANSPORT_FD_OFF);
>  
>  	fle = file_master(&peer->d);
>  	if (send_fd_to_peer(sk[1], fle, tsk)) {
> @@ -1092,7 +1088,6 @@ static int open_unixsk_pair_master(struct unix_sk_info *ui)
>  		return -1;
>  	}
>  
> -	close(tsk);
>  	close(sk[1]);
>  
>  	return sk[0];
> diff --git a/criu/tty.c b/criu/tty.c
> index ec09f30..b21b45a 100644
> --- a/criu/tty.c
> +++ b/criu/tty.c
> @@ -864,11 +864,7 @@ static int pty_open_slaves(struct tty_info *info)
>  	struct fdinfo_list_entry *fle;
>  	struct tty_info *slave;
>  
> -	sock = socket(PF_UNIX, SOCK_DGRAM, 0);
> -	if (sock < 0) {
> -		pr_perror("Can't create socket");
> -		goto err;
> -	}
> +	sock = get_service_fd(TRANSPORT_FD_OFF);
>  
>  	list_for_each_entry(slave, &info->sibling, sibling) {
>  		BUG_ON(tty_is_master(slave));
> @@ -900,7 +896,6 @@ static int pty_open_slaves(struct tty_info *info)
>  
>  err:
>  	close_safe(&fd);
> -	close_safe(&sock);
>  	return ret;
>  }
>  
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list