From: Matt Joiner Date: Wed, 3 Dec 2014 00:42:22 +0000 (-0600) Subject: When metadata arrives, we also need to init request ordering X-Git-Tag: v1.0.0~1430 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=a87e75357247d32606cfbeb690963e1cc4976b76;p=btrtrc.git When metadata arrives, we also need to init request ordering --- diff --git a/client.go b/client.go index 9cbf4aa7..cddb442f 100644 --- a/client.go +++ b/client.go @@ -892,7 +892,7 @@ func (me *Client) runConnection(sock net.Conn, torrent *torrent, discovery peerS }) } if torrent.haveInfo() { - me.initRequestOrdering(torrent, conn) + torrent.initRequestOrdering(conn) } err = me.connectionLoop(torrent, conn) if err != nil { @@ -902,7 +902,7 @@ func (me *Client) runConnection(sock net.Conn, torrent *torrent, discovery peerS 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 8e909a09..e4114e57 100644 --- a/torrent.go +++ b/torrent.go @@ -230,6 +230,7 @@ func (t *torrent) setMetadata(md metainfo.Info, dataDir string, infoBytes []byte } 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()