From 97f6cb496e8e942a3fd9b8a9ccc6a91cfdaeaad8 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 28 Nov 2016 00:03:10 +1100 Subject: [PATCH] Avoid deadlock caused by receiving PORT and and DHT announce_peer at the same time --- connection.go | 2 +- dht/server.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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. -- 2.50.0