Skip to content

Commit f51b554

Browse files
author
wmin0
committed
close bad connection to solve CLOSE_WAIT stuck
1 parent 9eb73ef commit f51b554

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
@@ -733,14 +733,6 @@ func TestCloseBadConn(t *testing.T) {
733733
defer cn.errRecover(&err)
734734
panic(io.EOF)
735735
}()
736-
// Verify we can write before closing.
737-
if _, err := nc.Write(nil); err != nil {
738-
t.Fatal(err)
739-
}
740-
// First close should close the connection.
741-
if err := cn.Close(); err != nil {
742-
t.Fatal(err)
743-
}
744736

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

error.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,4 +512,8 @@ func (c *conn) errRecover(err *error) {
512512
if *err == driver.ErrBadConn {
513513
c.bad = true
514514
}
515+
516+
if c.bad && c.c != nil {
517+
c.c.Close()
518+
}
515519
}

0 commit comments

Comments
 (0)