Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-reuseport-transport
Commits
c7583c88
Unverified
Commit
c7583c88
authored
Apr 04, 2019
by
Steven Allen
Committed by
GitHub
Apr 04, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14 from libp2p/fix/linger
don't set linger to 0
parents
501048f8
49f05fae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
10 deletions
+2
-10
reuseport.go
reuseport.go
+2
-10
No files found.
reuseport.go
View file @
c7583c88
...
@@ -39,7 +39,6 @@ func reuseErrShouldRetry(err error) bool {
...
@@ -39,7 +39,6 @@ func reuseErrShouldRetry(err error) bool {
}
}
// Dials using reuseport and then redials normally if that fails.
// Dials using reuseport and then redials normally if that fails.
// TODO(anacrolix): This shouldn't fail anymore: Remove fallback.
func
reuseDial
(
ctx
context
.
Context
,
laddr
*
net
.
TCPAddr
,
network
,
raddr
string
)
(
con
net
.
Conn
,
err
error
)
{
func
reuseDial
(
ctx
context
.
Context
,
laddr
*
net
.
TCPAddr
,
network
,
raddr
string
)
(
con
net
.
Conn
,
err
error
)
{
if
laddr
==
nil
{
if
laddr
==
nil
{
return
fallbackDialer
.
DialContext
(
ctx
,
network
,
raddr
)
return
fallbackDialer
.
DialContext
(
ctx
,
network
,
raddr
)
...
@@ -49,15 +48,6 @@ func reuseDial(ctx context.Context, laddr *net.TCPAddr, network, raddr string) (
...
@@ -49,15 +48,6 @@ func reuseDial(ctx context.Context, laddr *net.TCPAddr, network, raddr string) (
LocalAddr
:
laddr
,
LocalAddr
:
laddr
,
Control
:
reuseport
.
Control
,
Control
:
reuseport
.
Control
,
}
}
defer
func
()
{
if
err
!=
nil
{
return
}
// This is transplanted from go-reuseport, which once set no linger on
// dialing and may be a requirement for desired behaviour in this
// package.
con
.
(
*
net
.
TCPConn
)
.
SetLinger
(
0
)
}()
con
,
err
=
d
.
DialContext
(
ctx
,
network
,
raddr
)
con
,
err
=
d
.
DialContext
(
ctx
,
network
,
raddr
)
if
err
==
nil
{
if
err
==
nil
{
...
@@ -65,6 +55,8 @@ func reuseDial(ctx context.Context, laddr *net.TCPAddr, network, raddr string) (
...
@@ -65,6 +55,8 @@ func reuseDial(ctx context.Context, laddr *net.TCPAddr, network, raddr string) (
}
}
if
reuseErrShouldRetry
(
err
)
&&
ctx
.
Err
()
==
nil
{
if
reuseErrShouldRetry
(
err
)
&&
ctx
.
Err
()
==
nil
{
// We could have an existing socket open or we could have one
// stuck in TIME-WAIT.
log
.
Debugf
(
"failed to reuse port, dialing with a random port: %s"
,
err
)
log
.
Debugf
(
"failed to reuse port, dialing with a random port: %s"
,
err
)
con
,
err
=
fallbackDialer
.
DialContext
(
ctx
,
network
,
raddr
)
con
,
err
=
fallbackDialer
.
DialContext
(
ctx
,
network
,
raddr
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment