]> Sergey Matveev's repositories - btrtrc.git/commitdiff
dht.Server.query: Return nil Transaction if there's an error
authorMatt Joiner <anacrolix@gmail.com>
Tue, 17 May 2016 06:07:49 +0000 (16:07 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 17 May 2016 06:07:49 +0000 (16:07 +1000)
dht/server.go

index 37a5cc6bc34b0480e2bdeb65a0bfb534489008d3..c0f3127c557fa7acc623e6b0665eb0341b9d135f 100644 (file)
@@ -446,7 +446,7 @@ func (s *Server) query(node Addr, q string, a map[string]interface{}, onResponse
        if err != nil {
                return
        }
-       = &Transaction{
+       _t := &Transaction{
                remoteAddr:  node,
                t:           tid,
                response:    make(chan Msg, 1),
@@ -455,15 +455,16 @@ func (s *Server) query(node Addr, q string, a map[string]interface{}, onResponse
                s:           s,
                onResponse:  onResponse,
        }
-       err = t.sendQuery()
+       err = _t.sendQuery()
        if err != nil {
                return
        }
        s.getNode(node, "").lastSentQuery = time.Now()
-       t.mu.Lock()
-       t.startTimer()
-       t.mu.Unlock()
-       s.addTransaction(t)
+       _t.mu.Lock()
+       _t.startTimer()
+       _t.mu.Unlock()
+       s.addTransaction(_t)
+       t = _t
        return
 }