]> Sergey Matveev's repositories - btrtrc.git/commitdiff
We might want to close webseed peers on response errors
authorMatt Joiner <anacrolix@gmail.com>
Thu, 15 Oct 2020 01:45:19 +0000 (12:45 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 15 Oct 2020 01:45:19 +0000 (12:45 +1100)
webseed-peer.go

index 064a197cf8e7c79b50c1ad3ecfbdf1dea01521c8..4ed323725d655f5c55156a41eb43ec7e0168bbfa 100644 (file)
@@ -76,7 +76,11 @@ func (ws *webseedPeer) requestResultHandler(r request, webseedRequest webseed.Re
        defer ws.peer.t.cl.unlock()
        if result.Err != nil {
                ws.peer.logger.Printf("request %v rejected: %v", r, result.Err)
-               if strings.Contains(errors.Cause(result.Err).Error(), "unsupported protocol scheme") {
+               // Always close for now. We need to filter out temporary errors, but this is a nightmare in
+               // Go. Currently a bad webseed URL can starve out the good ones due to the chunk selection
+               // algorithm.
+               const closeOnAllErrors = false
+               if closeOnAllErrors || strings.Contains(errors.Cause(result.Err).Error(), "unsupported protocol scheme") {
                        ws.peer.close()
                } else {
                        ws.peer.remoteRejectedRequest(r)