From 021c9d5bcd7a54ef691156a7fe680c971088f840 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 16 Mar 2017 14:04:19 +0700 Subject: [PATCH] return an error when the network conn is closed in Listener.Serve() fixes #483 --- server.go | 4 ---- server_test.go | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/server.go b/server.go index 7ddb018bf..7f91c1a71 100644 --- a/server.go +++ b/server.go @@ -4,7 +4,6 @@ import ( "bytes" "errors" "net" - "strings" "sync" "time" @@ -88,9 +87,6 @@ func (s *server) Serve() error { // If it does, we only read a truncated packet, which will then end up undecryptable n, remoteAddr, err := s.conn.ReadFrom(data) if err != nil { - if strings.HasSuffix(err.Error(), "use of closed network connection") { - return nil - } return err } data = data[:n] diff --git a/server_test.go b/server_test.go index 25a0f8f55..5a575edd7 100644 --- a/server_test.go +++ b/server_test.go @@ -219,7 +219,8 @@ var _ = Describe("Server", func() { go func() { defer GinkgoRecover() err := ln.Serve() - Expect(err).ToNot(HaveOccurred()) + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("use of closed network connection")) returned = true }() ln.Close()