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
7cdd4bc9
Commit
7cdd4bc9
authored
Sep 13, 2017
by
Steven Allen
Browse files
Reset on error in basic_host
parent
1b9aa778
Changes
2
Hide whitespace changes
Inline
Side-by-side
p2p/host/basic/basic_host.go
View file @
7cdd4bc9
...
...
@@ -240,7 +240,7 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) {
if
h
.
negtimeout
>
0
{
if
err
:=
s
.
SetDeadline
(
time
.
Now
()
.
Add
(
h
.
negtimeout
));
err
!=
nil
{
log
.
Error
(
"setting stream deadline: "
,
err
)
s
.
Clo
se
()
s
.
Re
se
t
()
return
}
}
...
...
@@ -257,7 +257,7 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) {
}
else
{
log
.
Warning
(
"protocol mux failed: %s (took %s)"
,
err
,
took
)
}
s
.
Clo
se
()
s
.
Re
se
t
()
return
}
...
...
@@ -269,7 +269,7 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) {
if
h
.
negtimeout
>
0
{
if
err
:=
s
.
SetDeadline
(
time
.
Time
{});
err
!=
nil
{
log
.
Error
(
"resetting stream deadline: "
,
err
)
s
.
Clo
se
()
s
.
Re
se
t
()
return
}
}
...
...
@@ -364,7 +364,7 @@ func (h *BasicHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.I
selected
,
err
:=
msmux
.
SelectOneOf
(
protoStrs
,
s
)
if
err
!=
nil
{
s
.
Clo
se
()
s
.
Re
se
t
()
return
nil
,
err
}
selpid
:=
protocol
.
ID
(
selected
)
...
...
p2p/host/basic/basic_host_test.go
View file @
7cdd4bc9
...
...
@@ -180,7 +180,7 @@ func TestHostProtoMismatch(t *testing.T) {
h1
.
SetStreamHandler
(
"/super"
,
func
(
s
inet
.
Stream
)
{
t
.
Error
(
"shouldnt get here"
)
s
.
Clo
se
()
s
.
Re
se
t
()
})
_
,
err
:=
h2
.
NewStream
(
ctx
,
h1
.
ID
(),
"/foo"
,
"/bar"
,
"/baz/1.0.0"
)
...
...
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