From ef8e2fcf16d0338b17375b41bf6f4a9e105b952c Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 24 Jun 2014 23:17:06 +1000 Subject: [PATCH] DHT node table should be loaded after the server is initialized --- cmd/dht-server/main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/dht-server/main.go b/cmd/dht-server/main.go index 4b7cf8ab..b18dfc46 100644 --- a/cmd/dht-server/main.go +++ b/cmd/dht-server/main.go @@ -60,10 +60,7 @@ func loadTable() error { func init() { log.SetFlags(log.LstdFlags | log.Lshortfile) flag.Parse() - err := loadTable() - if err != nil { - log.Fatalf("error loading table: %s", err) - } + var err error s.Socket, err = net.ListenUDP("udp4", func() *net.UDPAddr { addr, err := net.ResolveUDPAddr("udp4", *serveAddr) if err != nil { @@ -74,8 +71,12 @@ func init() { if err != nil { log.Fatal(err) } - log.Printf("dht server on %s", s.Socket.LocalAddr()) s.Init() + err = loadTable() + if err != nil { + log.Fatalf("error loading table: %s", err) + } + log.Printf("dht server on %s, ID is %q", s.Socket.LocalAddr(), s.IDString()) setupSignals() }