The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8094

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===

From 365d4e97556e10d7997502dbaeb5de78bc4a4d90 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 28 Oct 2020 18:48:04 -0400
Subject: [PATCH 1/2] shared/cancel: Close chDone on failure
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 shared/cancel/canceler.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/shared/cancel/canceler.go b/shared/cancel/canceler.go
index b3356cf37e..51263b6020 100644
--- a/shared/cancel/canceler.go
+++ b/shared/cancel/canceler.go
@@ -69,5 +69,10 @@ func CancelableDownload(c *Canceler, client *http.Client, 
req *http.Request) (*h
        }()
 
        resp, err := client.Do(req)
-       return resp, chDone, err
+       if err != nil {
+               close(chDone)
+               return nil, nil, err
+       }
+
+       return resp, chDone, nil
 }

From 5dbef17cb415de8e3ef5acb3349ae4b77e61ceb9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 28 Oct 2020 18:48:20 -0400
Subject: [PATCH 2/2] lxd: Only close doneCh on success
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/daemon_images.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/daemon_images.go b/lxd/daemon_images.go
index 7e272a3a89..3a5b244d7e 100644
--- a/lxd/daemon_images.go
+++ b/lxd/daemon_images.go
@@ -401,10 +401,10 @@ func (d *Daemon) ImageDownload(op *operations.Operation, 
server string, protocol
 
                // Make the request
                raw, doneCh, err := cancel.CancelableDownload(canceler, 
httpClient, req)
-               defer close(doneCh)
                if err != nil {
                        return nil, err
                }
+               defer close(doneCh)
 
                if raw.StatusCode != http.StatusOK {
                        return nil, fmt.Errorf("Unable to fetch %q: %s", 
server, raw.Status)
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to