]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix crash printing client status if DHT isn't enabled
authorMatt Joiner <anacrolix@gmail.com>
Tue, 22 Jul 2014 15:50:49 +0000 (01:50 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 22 Jul 2014 15:50:49 +0000 (01:50 +1000)
client.go

index eeb04db540519a354907869f6aec29bf0a59fb86..4a42b17c759af9884d634ec3ac0e8ab400801e4d 100644 (file)
--- a/client.go
+++ b/client.go
@@ -121,7 +121,9 @@ func (cl *Client) WriteStatus(w io.Writer) {
        cl.mu.Lock()
        defer cl.mu.Unlock()
        fmt.Fprintf(w, "Half open: %d\n", cl.halfOpen)
-       fmt.Fprintf(w, "DHT nodes: %d\n", cl.DHT.NumNodes())
+       if cl.DHT != nil {
+               fmt.Fprintf(w, "DHT nodes: %d\n", cl.DHT.NumNodes())
+       }
        fmt.Fprintln(w)
        for _, t := range cl.torrents {
                fmt.Fprintf(w, "%s: %f%%\n", t.Name(), func() float32 {