Skip to content

net/http/httptest: investigate removing the net.Conn.Close goroutine for Go 1.7 #14291

@bradfitz

Description

@bradfitz

From an updated comment I'm writing in net/http/httptest/server.go:

func (s *Server) closeConn(c net.Conn) {
        if runtime.GOOS == "plan9" {
                // Go's Plan 9 net package isn't great at unblocking reads when
                // their underlying TCP connections are closed.  Don't trust
                // that that the ConnState state machine will get to
                // StateClosed. Instead, just go there directly. Plan 9 may leak
                // resources if the syscall doesn't end up returning. Oh well.
                s.forgetConn(c)
        }

        // Somewhere in the chaos of https://golang.org/cl/15151 we found that  
        // some types of conns were blocking in Close too long (or deadlocking?)
        // and we had to call Close in a goroutine. I (bradfitz) forget what                                                                                                       
        // that was at this point, but I suspect it was *tls.Conns, which                                                                                                          
        // were later fixed in https://golang.org/cl/18572, so this goroutine                                                                                                      
        // is _probably_ unnecessary now. But it's too late in Go 1.6 too remove                                                                                                   
        // it with confidence.                                                                                                                                                     
        // TODO(bradfitz): try to remove it for Go 1.7.                                                                                                                            
        go c.Close()
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions