Skip to content

Commit

Permalink
all: update ctx.Err() usage to context.Cause(ctx)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Apr 18, 2024
1 parent 743b2a8 commit ab1dc52
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion stores/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2050,7 +2050,7 @@ UPDATE objects SET health = (
}
select {
case <-ctx.Done():
return ctx.Err()
return context.Cause(ctx)
case <-time.After(time.Second):
}
}
Expand Down
2 changes: 1 addition & 1 deletion worker/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ loop:
case <-s.mgr.shutdownCtx.Done():
return nil, false, errors.New("download stopped")
case <-ctx.Done():
return nil, false, ctx.Err()
return nil, false, context.Cause(ctx)
case <-resps.c:
resetOverdrive()
}
Expand Down
2 changes: 1 addition & 1 deletion worker/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (h *testHost) UploadSector(ctx context.Context, sectorRoot types.Hash256, s
select {
case <-time.After(h.uploadDelay):
case <-ctx.Done():
return ctx.Err()
return context.Cause(ctx)
}
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion worker/pricetables.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (p *priceTable) fetch(ctx context.Context, rev *types.FileContractRevision)
} else if ongoing {
select {
case <-ctx.Done():
return api.HostPriceTable{}, fmt.Errorf("%w; %w", errPriceTableUpdateTimedOut, ctx.Err())
return api.HostPriceTable{}, fmt.Errorf("%w; %w", errPriceTableUpdateTimedOut, context.Cause(ctx))
case <-update.done:
}
return update.hpt, update.err
Expand Down
4 changes: 2 additions & 2 deletions worker/rhpv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ func (w *worker) withTransportV2(ctx context.Context, hostKey types.PublicKey, h
}()
defer func() {
close(done)
if ctx.Err() != nil {
err = ctx.Err()
if context.Cause(ctx) != nil {
err = context.Cause(ctx)
}
}()
t, err := rhpv2.NewRenterTransport(conn, hostKey)
Expand Down
2 changes: 1 addition & 1 deletion worker/rhpv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func dialTransport(ctx context.Context, siamuxAddr string, hostKey types.PublicK
case <-ctx.Done():
conn.Close()
<-done
return nil, ctx.Err()
return nil, context.Cause(ctx)
case <-done:
return t, err
}
Expand Down
2 changes: 1 addition & 1 deletion worker/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ loop:
case <-u.shutdownCtx.Done():
return nil, 0, 0, ErrShuttingDown
case <-ctx.Done():
return nil, 0, 0, ctx.Err()
return nil, 0, 0, context.Cause(ctx)
case resp := <-respChan:
// receive the response
used, done = slab.receive(resp)
Expand Down
4 changes: 2 additions & 2 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1431,7 +1431,7 @@ func (w *worker) scanHost(ctx context.Context, timeout time.Duration, hostKey ty
// scan: second try
select {
case <-ctx.Done():
return rhpv2.HostSettings{}, rhpv3.HostPriceTable{}, 0, ctx.Err()
return rhpv2.HostSettings{}, rhpv3.HostPriceTable{}, 0, context.Cause(ctx)
case <-time.After(time.Second):
}
settings, pt, duration, err = scan()
Expand All @@ -1449,7 +1449,7 @@ func (w *worker) scanHost(ctx context.Context, timeout time.Duration, hostKey ty
// repercussions
select {
case <-ctx.Done():
return rhpv2.HostSettings{}, rhpv3.HostPriceTable{}, 0, ctx.Err()
return rhpv2.HostSettings{}, rhpv3.HostPriceTable{}, 0, context.Cause(ctx)
default:
}

Expand Down

0 comments on commit ab1dc52

Please sign in to comment.