提交 ba094472 作者: Juan Batiz-Benet

mux: close stream on error

remove comment about spdystream. this is now
superceded by go-peerstream interface.
上级 53d190da
...@@ -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/net2"
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
} }
......
...@@ -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/net2"
) )
var testCases = map[string]string{ var testCases = map[string]string{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论