Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
3daf749d
提交
3daf749d
authored
7月 05, 2015
作者:
rht
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make sure process context is set last
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
上级
0ceac5de
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
5 行增加
和
7 行删除
+5
-7
swarm_dial.go
p2p/net/swarm/swarm_dial.go
+2
-2
dht.go
routing/dht/dht.go
+2
-1
query.go
routing/dht/query.go
+1
-4
没有找到文件。
p2p/net/swarm/swarm_dial.go
浏览文件 @
3daf749d
...
@@ -17,6 +17,7 @@ import (
...
@@ -17,6 +17,7 @@ import (
ma
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
ma
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
manet
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net"
manet
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net"
process
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
process
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
processctx
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
ratelimit
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit"
ratelimit
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
)
)
...
@@ -416,8 +417,7 @@ func (s *Swarm) dialAddrs(ctx context.Context, d *conn.Dialer, p peer.ID, remote
...
@@ -416,8 +417,7 @@ func (s *Swarm) dialAddrs(ctx context.Context, d *conn.Dialer, p peer.ID, remote
}
}
})
})
<-
ctx
.
Done
()
processctx
.
CloseAfterContext
(
limiter
,
ctx
)
limiter
.
Close
()
}()
}()
// wair fot the results.
// wair fot the results.
...
...
routing/dht/dht.go
浏览文件 @
3daf749d
...
@@ -73,7 +73,7 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.ThreadSafeDatastore) *Ip
...
@@ -73,7 +73,7 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.ThreadSafeDatastore) *Ip
// register for network notifs.
// register for network notifs.
dht
.
host
.
Network
()
.
Notify
((
*
netNotifiee
)(
dht
))
dht
.
host
.
Network
()
.
Notify
((
*
netNotifiee
)(
dht
))
dht
.
proc
=
goprocess
ctx
.
WithContextAndTeardown
(
ctx
,
func
()
error
{
dht
.
proc
=
goprocess
.
WithTeardown
(
func
()
error
{
// remove ourselves from network notifs.
// remove ourselves from network notifs.
dht
.
host
.
Network
()
.
StopNotify
((
*
netNotifiee
)(
dht
))
dht
.
host
.
Network
()
.
StopNotify
((
*
netNotifiee
)(
dht
))
return
nil
return
nil
...
@@ -84,6 +84,7 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.ThreadSafeDatastore) *Ip
...
@@ -84,6 +84,7 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.ThreadSafeDatastore) *Ip
h
.
SetStreamHandler
(
ProtocolDHT
,
dht
.
handleNewStream
)
h
.
SetStreamHandler
(
ProtocolDHT
,
dht
.
handleNewStream
)
dht
.
providers
=
NewProviderManager
(
dht
.
ctx
,
dht
.
self
)
dht
.
providers
=
NewProviderManager
(
dht
.
ctx
,
dht
.
self
)
dht
.
proc
.
AddChild
(
dht
.
providers
.
proc
)
dht
.
proc
.
AddChild
(
dht
.
providers
.
proc
)
goprocessctx
.
CloseAfterContext
(
dht
.
proc
,
ctx
)
dht
.
routingTable
=
kb
.
NewRoutingTable
(
20
,
kb
.
ConvertPeerID
(
dht
.
self
),
time
.
Minute
,
dht
.
peerstore
)
dht
.
routingTable
=
kb
.
NewRoutingTable
(
20
,
kb
.
ConvertPeerID
(
dht
.
self
),
time
.
Minute
,
dht
.
peerstore
)
dht
.
birth
=
time
.
Now
()
dht
.
birth
=
time
.
Now
()
...
...
routing/dht/query.go
浏览文件 @
3daf749d
...
@@ -127,10 +127,7 @@ func (r *dhtQueryRunner) Run(ctx context.Context, peers []peer.ID) (*dhtQueryRes
...
@@ -127,10 +127,7 @@ func (r *dhtQueryRunner) Run(ctx context.Context, peers []peer.ID) (*dhtQueryRes
// now, if the context finishes, close the proc.
// now, if the context finishes, close the proc.
// we have to do it here because the logic before is setup, which
// we have to do it here because the logic before is setup, which
// should run without closing the proc.
// should run without closing the proc.
go
func
()
{
ctxproc
.
CloseAfterContext
(
r
.
proc
,
ctx
)
<-
ctx
.
Done
()
r
.
proc
.
Close
()
}()
select
{
select
{
case
<-
r
.
peersRemaining
.
Done
()
:
case
<-
r
.
peersRemaining
.
Done
()
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论