Fix Shutdown

This commit is contained in:
Miek Gieben 2014-08-19 21:56:37 +01:00
parent f912994258
commit eed2b9aeec
2 changed files with 4 additions and 5 deletions

View File

@ -304,15 +304,14 @@ func (srv *Server) ActivateAndServe() error {
// ActivateAndServe will return. // ActivateAndServe will return.
func (srv *Server) Shutdown() { func (srv *Server) Shutdown() {
c := new(Client) c := new(Client)
c.Net = srv.Net
switch srv.Net { switch srv.Net {
case "tcp", "tcp4", "tcp6": case "tcp", "tcp4", "tcp6":
c.Net = "tcp"
go func() { srv.stopTCP <- true }() go func() { srv.stopTCP <- true }()
c.Exchange(new(Msg), srv.Addr)
case "udp", "udp4", "udp6": case "udp", "udp4", "udp6":
go func() { srv.stopUDP <- true }() go func() { srv.stopUDP <- true }()
c.Exchange(new(Msg), srv.Addr)
} }
c.Exchange(new(Msg), srv.Addr)
} }
// serveTCP starts a TCP listener for the server. // serveTCP starts a TCP listener for the server.

View File

@ -287,7 +287,7 @@ func TestShutdownTCP(t *testing.T) {
}() }()
time.Sleep(4e8) time.Sleep(4e8)
server.Shutdown() server.Shutdown()
time.Sleep(4e8) time.Sleep(1e9)
} }
func TestShutdownUDP(t *testing.T) { func TestShutdownUDP(t *testing.T) {
@ -302,5 +302,5 @@ func TestShutdownUDP(t *testing.T) {
}() }()
time.Sleep(4e8) time.Sleep(4e8)
server.Shutdown() server.Shutdown()
time.Sleep(4e8) time.Sleep(1e9)
} }