]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add dummy code for emulating the bug in #114
authorMatt Joiner <anacrolix@gmail.com>
Fri, 19 Jul 2019 03:07:40 +0000 (13:07 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 19 Jul 2019 03:07:40 +0000 (13:07 +1000)
Useful for ensuring that the test can still reproduce the issue with changes to encryption handling.

client.go

index 8180c14bbd662936f9f47963b851c516e0df5c10..fbf05d7ea40a1de3c38bb356fb9dd512968dbf9b 100644 (file)
--- a/client.go
+++ b/client.go
@@ -742,6 +742,19 @@ func (cl *Client) initiateHandshakes(c *connection, t *Torrent) (ok bool, err er
 func (cl *Client) forSkeys(f func([]byte) bool) {
        cl.lock()
        defer cl.unlock()
+       if false { // Emulate the bug from #114
+               var firstIh InfoHash
+               for ih := range cl.torrents {
+                       firstIh = ih
+                       break
+               }
+               for range cl.torrents {
+                       if !f(firstIh[:]) {
+                               break
+                       }
+               }
+               return
+       }
        for ih := range cl.torrents {
                if !f(ih[:]) {
                        break