webseedRequest.Close()
if err != nil {
level := slog.LevelInfo
- if webseedRequest.cancelled {
+ if webseedRequest.cancelled.Load() {
level = slog.LevelDebug
}
ws.slogger().Log(context.TODO(), level, "webseed request error", "err", err)
import (
"fmt"
+ "sync/atomic"
"github.com/anacrolix/torrent/webseed"
)
next RequestIndex
// One greater than the end of the range.
end RequestIndex
- cancelled bool
+ cancelled atomic.Bool
}
func (me *webseedRequest) Close() {
// Record that it was exceptionally cancelled.
func (me *webseedRequest) Cancel() {
me.request.Cancel()
- if !me.cancelled {
- me.cancelled = true
+ if !me.cancelled.Swap(true) {
if webseed.PrintDebug {
fmt.Printf("cancelled webseed request\n")
}