From 5b0af828be8b2deb8bc6d5f36c39556739072d7f Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Wed, 25 Jan 2012 14:42:18 +0200 Subject: [PATCH] unregistering servers without error --- src/inquirer/registration/registration.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/inquirer/registration/registration.go b/src/inquirer/registration/registration.go index c550dd36e..d54e78494 100644 --- a/src/inquirer/registration/registration.go +++ b/src/inquirer/registration/registration.go @@ -31,16 +31,21 @@ func (rl *RaterList) RegisterRater(clientAddress string, replay *byte) error { return err } rl.Clients[clientAddress] = client - log.Print(fmt.Sprintf("Server %v registered succesfully", clientAddress)) + log.Print(fmt.Sprintf("Rater %v registered succesfully.", clientAddress)) rl.balancer_mutex.Unlock() return nil } func (rl *RaterList) UnRegisterRater(clientAddress string, replay *byte) error { - client := rl.Clients[clientAddress] - client.Close() - delete(rl.Clients, clientAddress) - log.Print(fmt.Sprintf("Server %v unregistered succesfully", clientAddress)) + + client, ok := rl.Clients[clientAddress] + if ok { + client.Close() + delete(rl.Clients, clientAddress) + log.Print(fmt.Sprintf("Rater %v unregistered succesfully.", clientAddress)) + } else { + log.Print(fmt.Sprintf("Server %v was not on my watch!", clientAddress)) + } return nil }