Skip to content

Commit d6e1f31

Browse files
author
wmin0
committed
close bad connection to solve CLOSE_WAIT stuck
1 parent 88edab0 commit d6e1f31

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

conn_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -732,14 +732,6 @@ func TestCloseBadConn(t *testing.T) {
732732
defer cn.errRecover(&err)
733733
panic(io.EOF)
734734
}()
735-
// Verify we can write before closing.
736-
if _, err := nc.Write(nil); err != nil {
737-
t.Fatal(err)
738-
}
739-
// First close should close the connection.
740-
if err := cn.Close(); err != nil {
741-
t.Fatal(err)
742-
}
743735

744736
// During the Go 1.9 cycle, https://github.com/golang/go/commit/3792db5
745737
// changed this error from

error.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,4 +506,8 @@ func (c *conn) errRecover(err *error) {
506506
if *err == driver.ErrBadConn {
507507
c.bad = true
508508
}
509+
510+
if c.bad && c.c != nil {
511+
c.c.Close()
512+
}
509513
}

0 commit comments

Comments
 (0)