Skip to content

Commit

Permalink
Enable cancellation during file sync
Browse files Browse the repository at this point in the history
Longhorn #2416

Signed-off-by: Shuo Wu <shuo.wu@suse.com>
  • Loading branch information
shuo-wu authored and innobead committed Apr 14, 2021
1 parent 01cac31 commit ef2e372
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/server/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (d *BackingImageDownloader) Receive(port string, filePath string, syncFileO
d.Cancel()
return fmt.Errorf("BUG: downloader gets duplicate receive requests during downloading")
}
_, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(context.Background())
d.Lock()
d.cancelFunc = cancel
d.Unlock()
Expand All @@ -76,7 +76,7 @@ func (d *BackingImageDownloader) Receive(port string, filePath string, syncFileO
d.Cancel()
}()

if err := sparserest.Server(port, filePath, syncFileOps); err != nil && err != http.ErrServerClosed {
if err := sparserest.Server(ctx, cancel, port, filePath, syncFileOps); err != nil && err != http.ErrServerClosed {
return err
}
return nil
Expand Down

0 comments on commit ef2e372

Please sign in to comment.