Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
6036b043
提交
6036b043
authored
4月 08, 2015
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1038 from ipfs/reuseport-disable
reuseport: env var to turn it off
上级
20dbea5e
f1566e23
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
37 行增加
和
2 行删除
+37
-2
dial.go
p2p/net/conn/dial.go
+1
-1
listen.go
p2p/net/conn/listen.go
+1
-1
reuseport.go
p2p/net/conn/reuseport.go
+35
-0
没有找到文件。
p2p/net/conn/dial.go
浏览文件 @
6036b043
...
...
@@ -118,7 +118,7 @@ func (d *Dialer) rawConnDial(ctx context.Context, raddr ma.Multiaddr, remote pee
// make a copy of the manet.Dialer, we may need to change its timeout.
madialer
:=
d
.
Dialer
if
laddr
!=
nil
&&
reuseport
.
Available
()
{
if
laddr
!=
nil
&&
reuseport
Is
Available
()
{
// we're perhaps going to dial twice. half the timeout, so we can afford to.
// otherwise our context would expire right after the first dial.
madialer
.
Dialer
.
Timeout
=
(
madialer
.
Dialer
.
Timeout
/
2
)
...
...
p2p/net/conn/listen.go
浏览文件 @
6036b043
...
...
@@ -169,7 +169,7 @@ func manetListen(addr ma.Multiaddr) (manet.Listener, error) {
return
nil
,
err
}
if
reuseport
.
Available
()
{
if
reuseport
Is
Available
()
{
nl
,
err
:=
reuseport
.
Listen
(
network
,
naddr
)
if
err
==
nil
{
// hey, it worked!
...
...
p2p/net/conn/reuseport.go
0 → 100644
浏览文件 @
6036b043
package
conn
import
(
"os"
"strings"
reuseport
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-reuseport"
)
// envReuseport is the env variable name used to turn off reuse port.
// It default to true.
const
envReuseport
=
"IPFS_REUSEPORT"
// envReuseportVal stores the value of envReuseport. defaults to true.
var
envReuseportVal
=
true
func
init
()
{
v
:=
strings
.
ToLower
(
os
.
Getenv
(
envReuseport
))
if
v
==
"false"
||
v
==
"f"
||
v
==
"0"
{
envReuseportVal
=
false
log
.
Infof
(
"REUSEPORT disabled (IPFS_REUSEPORT=%s)"
,
v
)
}
}
// reuseportIsAvailable returns whether reuseport is available to be used. This
// is here because we want to be able to turn reuseport on and off selectively.
// For now we use an ENV variable, as this handles our pressing need:
//
// IPFS_REUSEPORT=false ipfs daemon
//
// If this becomes a sought after feature, we could add this to the config.
// In the end, reuseport is a stop-gap.
func
reuseportIsAvailable
()
bool
{
return
envReuseportVal
&&
reuseport
.
Available
()
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论