udp: fix nil ptr when socket fails to be created

This commit is contained in:
Jimmy Zelinskie 2015-07-08 20:21:35 -04:00
parent e27fbe9652
commit 6b53ceb2a3

View file

@ -41,11 +41,11 @@ func (s *Server) serve(listenAddr string) error {
} }
sock, err := net.ListenUDP("udp", udpAddr) sock, err := net.ListenUDP("udp", udpAddr)
defer sock.Close()
if err != nil { if err != nil {
close(s.booting) close(s.booting)
return err return err
} }
defer sock.Close()
if s.config.UDPReadBufferSize > 0 { if s.config.UDPReadBufferSize > 0 {
sock.SetReadBuffer(s.config.UDPReadBufferSize) sock.SetReadBuffer(s.config.UDPReadBufferSize)