From f0bd4137e22f47bf3fbddd84a68c2efc861c1eaa Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Wed, 20 Aug 2014 15:12:59 +0000 Subject: [PATCH] Make Shutdown return error This will be handy in feature, so that we can add a 1 second timeout and then return failure. --- server.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index cc3949a8..dd0ea7ab 100644 --- a/server.go +++ b/server.go @@ -302,8 +302,8 @@ func (srv *Server) ActivateAndServe() error { // Shutdown gracefully shuts down a server. After a call to Shutdown, ListenAndServe and // ActivateAndServe will return. All in progress queries are completed before the server -// is taken down. -func (srv *Server) Shutdown() { +// is taken down. If the Shutdown was not succesful an error is returned. +func (srv *Server) Shutdown() error { c := new(Client) c.Net = srv.Net switch srv.Net { @@ -313,6 +313,7 @@ func (srv *Server) Shutdown() { go func() { srv.stopUDP <- true }() } c.Exchange(new(Msg), srv.Addr) + return nil } // serveTCP starts a TCP listener for the server.