Fix Shutdown
This commit is contained in:
parent
f912994258
commit
eed2b9aeec
|
@ -304,15 +304,14 @@ func (srv *Server) ActivateAndServe() error {
|
|||
// ActivateAndServe will return.
|
||||
func (srv *Server) Shutdown() {
|
||||
c := new(Client)
|
||||
c.Net = srv.Net
|
||||
switch srv.Net {
|
||||
case "tcp", "tcp4", "tcp6":
|
||||
c.Net = "tcp"
|
||||
go func() { srv.stopTCP <- true }()
|
||||
c.Exchange(new(Msg), srv.Addr)
|
||||
case "udp", "udp4", "udp6":
|
||||
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.
|
||||
|
|
|
@ -287,7 +287,7 @@ func TestShutdownTCP(t *testing.T) {
|
|||
}()
|
||||
time.Sleep(4e8)
|
||||
server.Shutdown()
|
||||
time.Sleep(4e8)
|
||||
time.Sleep(1e9)
|
||||
}
|
||||
|
||||
func TestShutdownUDP(t *testing.T) {
|
||||
|
@ -302,5 +302,5 @@ func TestShutdownUDP(t *testing.T) {
|
|||
}()
|
||||
time.Sleep(4e8)
|
||||
server.Shutdown()
|
||||
time.Sleep(4e8)
|
||||
time.Sleep(1e9)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue