From a87e75357247d32606cfbeb690963e1cc4976b76 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 2 Dec 2014 18:42:22 -0600 Subject: [PATCH] When metadata arrives, we also need to init request ordering --- client.go | 4 ++-- torrent.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) 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() -- 2.48.1