From 93e07e83bb197ce356a596dc8e57f134c3ce5fef Mon Sep 17 00:00:00 2001 From: Andrea Barberio Date: Thu, 27 Sep 2018 19:54:19 +0100 Subject: Addressed feedback --- dhcpv6/server.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'dhcpv6/server.go') diff --git a/dhcpv6/server.go b/dhcpv6/server.go index 4dbb0e1..3fade87 100644 --- a/dhcpv6/server.go +++ b/dhcpv6/server.go @@ -67,7 +67,7 @@ type Server struct { localAddr net.UDPAddr } -// LocalAddr returns the local address of the listening socked, or nil if not +// LocalAddr returns the local address of the listening socket, or nil if not // listening func (s *Server) LocalAddr() net.Addr { s.connMutex.Lock() @@ -88,6 +88,10 @@ func (s *Server) ActivateAndServe() error { } s.conn = conn } + defer func() { + s.conn.Close() + s.conn = nil + }() s.connMutex.Unlock() var ( pc *net.UDPConn @@ -102,7 +106,6 @@ func (s *Server) ActivateAndServe() error { log.Printf("Server listening on %s", pc.LocalAddr()) log.Print("Ready to handle requests") for { - log.Printf("CHECK") select { case <-s.shouldStop: break @@ -129,7 +132,6 @@ func (s *Server) ActivateAndServe() error { } s.Handler(pc, peer, m) } - s.conn.Close() return nil } -- cgit v1.2.3