diff --git a/server.go b/server.go index 7ffd1e13..e52fb851 100644 --- a/server.go +++ b/server.go @@ -333,7 +333,7 @@ func (srv *Server) Shutdown() error { select { case <-time.After(srv.getReadTimeout()): - return &Error{err: "shutdown is pending"} + return &Error{err: "server shutdown is pending"} case <-fin: return nil } diff --git a/server_test.go b/server_test.go index 3264a358..4041468d 100644 --- a/server_test.go +++ b/server_test.go @@ -40,6 +40,10 @@ func RunLocalUDPServer(laddr string) (*Server, string, error) { server.ActivateAndServe() pc.Close() }() + // in order to let all Server internals to finish before test will touch + // server's internal fields, we need to cycle thru other goroutinges for + // one more time + runtime.Gosched() return server, pc.LocalAddr().String(), nil } @@ -53,6 +57,10 @@ func RunLocalTCPServer(laddr string) (*Server, string, error) { server.ActivateAndServe() l.Close() }() + // in order to let all Server internals to finish before test will touch + // server's internal fields, we need to cycle thru other goroutinges for + // one more time + runtime.Gosched() return server, l.Addr().String(), nil } @@ -260,15 +268,13 @@ func HelloServerLargeResponse(resp ResponseWriter, req *Msg) { } func TestServingLargeResponses(t *testing.T) { - mux := NewServeMux() - mux.HandleFunc("example.", HelloServerLargeResponse) + HandleFunc("example.", HelloServerLargeResponse) s, addrstr, err := RunLocalUDPServer("127.0.0.1:0") if err != nil { t.Fatalf("Unable to run test server: %s", err) } defer s.Shutdown() - s.Handler = mux // Create request m := new(Msg)