return an error when the network conn is closed in Listener.Serve()

fixes #483
This commit is contained in:
Marten Seemann
2017-03-16 14:04:19 +07:00
parent 6d0ac39cf7
commit 021c9d5bcd
2 changed files with 2 additions and 5 deletions

View File

@@ -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]

View File

@@ -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()