image-cache: Ignore SIGPIPE

Submitted by Radostin Stoyanov on July 9, 2018, 6:43 p.m.

Details

Message ID 20180709184320.16116-1-rstoyanov1@gmail.com
State New
Series "image-cache: Ignore SIGPIPE"
Headers show

Commit Message

Radostin Stoyanov July 9, 2018, 6:43 p.m.
During restore, the function send_image_async() is writing to a socket.
However, this might fail with EPIPE (Broken pipe), causing the image-cache
process to receive SIGPIPE.

The default behaviour for this signal is to terminate the process, causing
the restore to fail with:

    Restore side is calling finish
    Error (criu/img-remote.c:287): Unable to connect to local socket: img-cache.sock: Connection refused
    Error (criu/img-remote.c:1093): Error opening local connection for RESTORE_FINISH:null
    Error (criu/img-remote.c:1154): Unable to open finish restore connection
    Error (criu/cr-restore.c:2661): Finish remote restore failed.

This patch is ignores SIGPIPE and allows the send_image_async() to
handle EPIPE.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
---
 criu/img-remote.c | 1 +
 1 file changed, 1 insertion(+)

Patch hide | download patch | download mbox

diff --git a/criu/img-remote.c b/criu/img-remote.c
index f148e23f..9d1cd347 100644
--- a/criu/img-remote.c
+++ b/criu/img-remote.c
@@ -925,6 +925,7 @@  void accept_image_connections() {
 			pr_perror("Failed to add proxy to cache fd to epoll");
 			goto end;
 		}
+		signal(SIGPIPE, SIG_IGN);
 	}
 
 	while (1) {

Comments

Andrey Vagin July 11, 2018, 6:46 a.m.
On Mon, Jul 09, 2018 at 07:43:20PM +0100, Radostin Stoyanov wrote:
> During restore, the function send_image_async() is writing to a socket.
> However, this might fail with EPIPE (Broken pipe), causing the image-cache
> process to receive SIGPIPE.

SIGPIPE means that we are trying to write into a socket which was closed
from another side. Usually, this means that something is going wrong,
isn't it?

> 
> The default behaviour for this signal is to terminate the process, causing
> the restore to fail with:
> 
>     Restore side is calling finish
>     Error (criu/img-remote.c:287): Unable to connect to local socket: img-cache.sock: Connection refused
>     Error (criu/img-remote.c:1093): Error opening local connection for RESTORE_FINISH:null
>     Error (criu/img-remote.c:1154): Unable to open finish restore connection
>     Error (criu/cr-restore.c:2661): Finish remote restore failed.
> 
> This patch is ignores SIGPIPE and allows the send_image_async() to
> handle EPIPE.
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
> ---
>  criu/img-remote.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/criu/img-remote.c b/criu/img-remote.c
> index f148e23f..9d1cd347 100644
> --- a/criu/img-remote.c
> +++ b/criu/img-remote.c
> @@ -925,6 +925,7 @@ void accept_image_connections() {
>  			pr_perror("Failed to add proxy to cache fd to epoll");
>  			goto end;
>  		}
> +		signal(SIGPIPE, SIG_IGN);
>  	}
>  
>  	while (1) {
> -- 
> 2.17.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu