Merge pull request #485 from lucas-clemente/fix-483

return an error when the network conn is closed in Listener.Serve()
This commit is contained in:
Marten Seemann
2017-03-17 10:11:04 +07:00
committed by GitHub
2 changed files with 2 additions and 5 deletions

View File

@@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"errors" "errors"
"net" "net"
"strings"
"sync" "sync"
"time" "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 // If it does, we only read a truncated packet, which will then end up undecryptable
n, remoteAddr, err := s.conn.ReadFrom(data) n, remoteAddr, err := s.conn.ReadFrom(data)
if err != nil { if err != nil {
if strings.HasSuffix(err.Error(), "use of closed network connection") {
return nil
}
return err return err
} }
data = data[:n] data = data[:n]

View File

@@ -219,7 +219,8 @@ var _ = Describe("Server", func() {
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
err := ln.Serve() err := ln.Serve()
Expect(err).ToNot(HaveOccurred()) Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("use of closed network connection"))
returned = true returned = true
}() }()
ln.Close() ln.Close()