Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
7d6f9521
Unverified
Commit
7d6f9521
authored
Aug 21, 2018
by
Steven Allen
Committed by
GitHub
Aug 21, 2018
Browse files
Merge pull request #380 from libp2p/fix/reset-ping-stream
always reset ping streams when done
parents
6f0dcfa1
72df25af
Changes
1
Hide whitespace changes
Inline
Side-by-side
p2p/protocol/ping/ping.go
View file @
7d6f9521
...
...
@@ -44,19 +44,14 @@ func (p *PingService) PingHandler(s inet.Stream) {
select
{
case
<-
timer
.
C
:
log
.
Debug
(
"ping timeout"
)
s
.
Reset
()
case
err
,
ok
:=
<-
errCh
:
if
ok
{
log
.
Debug
(
err
)
if
err
==
io
.
EOF
{
s
.
Close
()
}
else
{
s
.
Reset
()
}
}
else
{
log
.
Error
(
"ping loop failed without error"
)
}
}
s
.
Reset
()
}()
for
{
...
...
@@ -85,7 +80,7 @@ func (ps *PingService) Ping(ctx context.Context, p peer.ID) (<-chan time.Duratio
out
:=
make
(
chan
time
.
Duration
)
go
func
()
{
defer
close
(
out
)
defer
s
.
Clo
se
()
defer
s
.
Re
se
t
()
for
{
select
{
case
<-
ctx
.
Done
()
:
...
...
@@ -93,7 +88,6 @@ func (ps *PingService) Ping(ctx context.Context, p peer.ID) (<-chan time.Duratio
default
:
t
,
err
:=
ping
(
s
)
if
err
!=
nil
{
s
.
Reset
()
log
.
Debugf
(
"ping error: %s"
,
err
)
return
}
...
...
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