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
2c6c64b2
Commit
2c6c64b2
authored
Dec 31, 2014
by
Juan Batiz-Benet
Browse files
mux: close stream on error
remove comment about spdystream. this is now superceded by go-peerstream interface.
parent
1d3554e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
protocol/mux.go
View file @
2c6c64b2
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
inet
"github.com/jbenet/go-ipfs/p2p/net"
inet
"github.com/jbenet/go-ipfs/p2p/net
2
"
eventlog
"github.com/jbenet/go-ipfs/util/eventlog"
eventlog
"github.com/jbenet/go-ipfs/util/eventlog"
lgbl
"github.com/jbenet/go-ipfs/util/eventlog/loggables"
lgbl
"github.com/jbenet/go-ipfs/util/eventlog/loggables"
)
)
...
@@ -87,19 +87,6 @@ func (m *Mux) SetHandler(p ID, h inet.StreamHandler) {
...
@@ -87,19 +87,6 @@ func (m *Mux) SetHandler(p ID, h inet.StreamHandler) {
// Handle reads the next name off the Stream, and calls a handler function
// Handle reads the next name off the Stream, and calls a handler function
// This is done in its own goroutine, to avoid blocking the caller.
// This is done in its own goroutine, to avoid blocking the caller.
func
(
m
*
Mux
)
Handle
(
s
inet
.
Stream
)
{
func
(
m
*
Mux
)
Handle
(
s
inet
.
Stream
)
{
// Flow control and backpressure of Opening streams is broken.
// I believe that spdystream has one set of workers that both send
// data AND accept new streams (as it's just more data). there
// is a problem where if the new stream handlers want to throttle,
// they also eliminate the ability to read/write data, which makes
// forward-progress impossible. Thus, throttling this function is
// -- at this moment -- not the solution. Either spdystream must
// change, or we must throttle another way.
//
// In light of this, we use a goroutine for now (otherwise the
// spdy worker totally blocks, and we can't even read the protocol
// header). The better route in the future is to use a worker pool.
go
m
.
HandleSync
(
s
)
go
m
.
HandleSync
(
s
)
}
}
...
@@ -114,6 +101,7 @@ func (m *Mux) HandleSync(s inet.Stream) {
...
@@ -114,6 +101,7 @@ func (m *Mux) HandleSync(s inet.Stream) {
err
=
fmt
.
Errorf
(
"protocol mux error: %s"
,
err
)
err
=
fmt
.
Errorf
(
"protocol mux error: %s"
,
err
)
log
.
Error
(
err
)
log
.
Error
(
err
)
log
.
Event
(
ctx
,
"muxError"
,
lgbl
.
Error
(
err
))
log
.
Event
(
ctx
,
"muxError"
,
lgbl
.
Error
(
err
))
s
.
Close
()
return
return
}
}
...
...
protocol/mux_test.go
View file @
2c6c64b2
...
@@ -4,7 +4,7 @@ import (
...
@@ -4,7 +4,7 @@ import (
"bytes"
"bytes"
"testing"
"testing"
inet
"github.com/jbenet/go-ipfs/p2p/net"
inet
"github.com/jbenet/go-ipfs/p2p/net
2
"
)
)
var
testCases
=
map
[
string
]
string
{
var
testCases
=
map
[
string
]
string
{
...
...
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