[lxc-devel] [lxd/master] lxd/rsync: Tweaks Recv's internal synchronisation to avoid race

tomponline on Github lxc-bot at linuxcontainers.org
Sat Nov 2 19:06:35 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 883 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191102/13b0fc7a/attachment.bin>
-------------- next part --------------
From b9cfe585305106359d0333e8950a072a08d5dbd0 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Sat, 2 Nov 2019 19:03:57 +0000
Subject: [PATCH] lxd/rsync: Tweaks Recv's internal synchronisation to avoid
 race

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/rsync/rsync.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lxd/rsync/rsync.go b/lxd/rsync/rsync.go
index d9ac02fcd3..d5d0ee1320 100644
--- a/lxd/rsync/rsync.go
+++ b/lxd/rsync/rsync.go
@@ -276,9 +276,9 @@ func Recv(path string, conn io.ReadWriteCloser, tracker *ioprogress.ProgressTrac
 	chCopyRsync := make(chan error, 1)
 	go func() {
 		_, err := io.Copy(conn, stdout)
-		chCopyRsync <- err
 		stdout.Close()
 		conn.Close() // sends barrier message.
+		chCopyRsync <- err
 	}()
 
 	// Forward from source to rsync.
@@ -298,8 +298,8 @@ func Recv(path string, conn io.ReadWriteCloser, tracker *ioprogress.ProgressTrac
 	chCopySource := make(chan error, 1)
 	go func() {
 		_, err := io.Copy(stdin, readSourcePipe)
-		chCopySource <- err
 		stdin.Close()
+		chCopySource <- err
 	}()
 
 	stderr, err := cmd.StderrPipe()


More information about the lxc-devel mailing list