From 8a3f2a9a2e6ecc7a71397e567da03e4046d73443 Mon Sep 17 00:00:00 2001 From: "Stanislav N. aka pztrn" Date: Fri, 4 Nov 2016 19:37:50 +0500 Subject: [PATCH] Stop updating servers if we're failed to connect to master server. --- requester/requester_object.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/requester/requester_object.go b/requester/requester_object.go index 40e8ada..8947ec1 100644 --- a/requester/requester_object.go +++ b/requester/requester_object.go @@ -12,6 +12,7 @@ package requester import ( // stdlib "bytes" + "errors" "fmt" "net" "strconv" @@ -46,11 +47,13 @@ func (r *Requester) Initialize() { // Gets all available servers from master server. // This isn't in pooler, because it have no need to be pooled. -func (r *Requester) getServers() { +func (r *Requester) getServers() error { // IP addresses we will compose to return. conn, err1 := net.Dial("udp", r.master_server + ":" + r.master_server_port) if err1 != nil { fmt.Println("Error dialing to master server!") + Eventer.LaunchEvent("setToolbarLabelText", map[string]string{"text": "Failed to connect to master server!"}) + return errors.New("Failed to connect to master server!") } defer conn.Close() @@ -118,6 +121,8 @@ func (r *Requester) getServers() { Cache.Servers[addr].Server.Port = port } } + + return nil } // Updates information about all available servers from master server and