Fixes to closing torrents and connections

This commit is contained in:
Matt Joiner 2014-08-28 10:04:44 +10:00
parent 1507d803bd
commit e09e21fab2
1 changed files with 2 additions and 4 deletions

View File

@ -267,9 +267,7 @@ func (me *Client) Stop() {
close(me.quit) close(me.quit)
me.event.Broadcast() me.event.Broadcast()
for _, t := range me.torrents { for _, t := range me.torrents {
for _, c := range t.Conns { t.Close()
c.Close()
}
} }
me.mu.Unlock() me.mu.Unlock()
} }
@ -929,10 +927,10 @@ func (me *Client) connectionLoop(t *torrent, c *connection) error {
} }
func (me *Client) dropConnection(torrent *torrent, conn *connection) { func (me *Client) dropConnection(torrent *torrent, conn *connection) {
conn.Socket.Close()
for r := range conn.Requests { for r := range conn.Requests {
me.connDeleteRequest(torrent, conn, r) me.connDeleteRequest(torrent, conn, r)
} }
conn.Close()
for i0, c := range torrent.Conns { for i0, c := range torrent.Conns {
if c != conn { if c != conn {
continue continue