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
d1f0342a
Commit
d1f0342a
authored
Jan 02, 2019
by
Matt Joiner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add SetLinger(0) in reuseDial
No longer implicitly provided by go-reuseport's Dialer as it was removed.
parent
fed46568
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
reuseport.go
reuseport.go
+13
-3
No files found.
reuseport.go
View file @
d1f0342a
...
...
@@ -38,8 +38,9 @@ func reuseErrShouldRetry(err error) bool {
}
}
// Dials using reusport and then redials normally if that fails.
func
reuseDial
(
ctx
context
.
Context
,
laddr
*
net
.
TCPAddr
,
network
,
raddr
string
)
(
net
.
Conn
,
error
)
{
// 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
)
{
if
laddr
==
nil
{
return
fallbackDialer
.
DialContext
(
ctx
,
network
,
raddr
)
}
...
...
@@ -48,8 +49,17 @@ func reuseDial(ctx context.Context, laddr *net.TCPAddr, network, raddr string) (
LocalAddr
:
laddr
,
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
{
return
con
,
nil
}
...
...
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