Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: DialTimeout does not clean up fd immediately #2631

Closed
gopherbot opened this issue Dec 29, 2011 · 6 comments
Closed

net: DialTimeout does not clean up fd immediately #2631

gopherbot opened this issue Dec 29, 2011 · 6 comments
Milestone

Comments

@gopherbot
Copy link

by emilliken:

What steps will reproduce the problem?
I was making many connections via net.DialTimeout and descriptors were not getting
closed immediately after timeout, but rather after the OS-defined connect() timeout was
reached. This was causing my code to run out of descriptors, according to
net.DialTimeout. To demo, run lsof 5 seconds after running this code and see that the
dial descriptor has not been freed.

package main

import (
        "fmt"
        "net"
        "os"
        "time"
)

const ( 
        NORESP = "10.0.0.5:11"
)

func main() {
        fmt.Printf("begin.\n")
        c, err := net.DialTimeout("tcp4", NORESP, 5*time.Second)
        if err != nil {
                fmt.Printf("%v\n", err)
        } else {
                fmt.Printf("did not timeout.\n")
                c.Close()
                os.Exit(1)
        }
        fmt.Printf("selecting.\n")
        select {}
}

What is the expected output?


What do you see instead?


Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
freebsd amd64

Which revision are you using?  (hg identify)
weekly.2011-12-22

Please provide any additional information below.
@bradfitz
Copy link
Contributor

Comment 1:

Yes, there's a TODO in the code about this.  In practice this shouldn't matter since
they're closed in 3 minutes and your fd ulimit should be high enough to survive for 3
minutes, but this should be fixed.

Status changed to Accepted.

@adg
Copy link
Contributor

adg commented Jan 4, 2012

Comment 2:

Labels changed: added priority-later, removed priority-triage.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 4:

Labels changed: added go1.1.

@bradfitz
Copy link
Contributor

Comment 5:

Initial version at http://golang.org/cl/6575050

@bradfitz
Copy link
Contributor

Comment 6:

Better version (still a work in progress) at http://golang.org/cl/6815049

Owner changed to @bradfitz.

@bradfitz
Copy link
Contributor

bradfitz commented Nov 8, 2012

Comment 7:

This issue was closed by revision ef6806f.

Status changed to Fixed.

fern4lvarez pushed a commit to cloudControl/hipache-hchecker that referenced this issue Mar 24, 2015
A go version with this issue fixed helps to mitigate this issue,
too: golang/go#2631
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants