client.go | 4 ++-- torrent.go | 1 + diff --git a/client.go b/client.go index 9cbf4aa7923d21b1da9230200426fc6917c9ea4c..cddb442f305b0303a627bc6723be6f363e695879 100644 --- a/client.go +++ b/client.go @@ -892,7 +892,7 @@ Port: uint16(addr.Port), }) } if torrent.haveInfo() { - me.initRequestOrdering(torrent, conn) + torrent.initRequestOrdering(conn) } err = me.connectionLoop(torrent, conn) if err != nil { @@ -902,7 +902,7 @@ me.dropConnection(torrent, conn) return } -func (cl *Client) initRequestOrdering(t *torrent, c *connection) { +func (t *torrent) initRequestOrdering(c *connection) { if c.pieceRequestOrder != nil || c.piecePriorities != nil { panic("double init of request ordering") } diff --git a/torrent.go b/torrent.go index 8e909a0984660ce7def09c2390f01dd2d581be96..e4114e576ba3f9029d4401694432626ea49d1475 100644 --- a/torrent.go +++ b/torrent.go @@ -230,6 +230,7 @@ t.pendAllChunkSpecs(pp.Integer(index)) } t.assertIncompletePiecesByBytesLeftOrdering() for _, conn := range t.Conns { + t.initRequestOrdering(conn) if err := conn.setNumPieces(t.NumPieces()); err != nil { log.Printf("closing connection: %s", err) conn.Close()