From: Matt Joiner Date: Sun, 27 Nov 2016 13:03:10 +0000 (+1100) Subject: Avoid deadlock caused by receiving PORT and and DHT announce_peer at the same time X-Git-Tag: v1.0.0~520 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=97f6cb496e8e942a3fd9b8a9ccc6a91cfdaeaad8;p=btrtrc.git Avoid deadlock caused by receiving PORT and and DHT announce_peer at the same time --- diff --git a/connection.go b/connection.go index 1d67e9dc..60ebb232 100644 --- a/connection.go +++ b/connection.go @@ -902,7 +902,7 @@ func (c *connection) mainReadLoop() error { if msg.Port != 0 { pingAddr.Port = int(msg.Port) } - cl.dHT.Ping(pingAddr) + go cl.dHT.Ping(pingAddr) default: err = fmt.Errorf("received unknown message type: %#v", msg.Type) } diff --git a/dht/server.go b/dht/server.go index 74b56cf6..7e910979 100644 --- a/dht/server.go +++ b/dht/server.go @@ -331,7 +331,7 @@ func (s *Server) handleQuery(source Addr, m krpc.Msg) { if args.ImpliedPort != 0 { p.Port = source.UDPAddr().Port } - h(ih, p) + go h(ih, p) } case "vote": // TODO(anacrolix): Or reject, I don't think I want this.