mux: close stream on error
remove comment about spdystream. this is now superceded by go-peerstream interface.
Juan Batiz-Benet committed
Dec 31, 2014 at 20:33 UTC
ba094472515888c52a521b6fc876c02121d5bad8
2 files changed
+3
-15
p2p/protocol/mux.go
+2
-14
@@ -7,7 +7,7 @@ import (
7
8
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
9
10
- inet "github.com/jbenet/go-ipfs/p2p/net"
10
+ inet "github.com/jbenet/go-ipfs/p2p/net2"
11
eventlog "github.com/jbenet/go-ipfs/util/eventlog"
12
lgbl "github.com/jbenet/go-ipfs/util/eventlog/loggables"
13
)
@@ -87,19 +87,6 @@ func (m *Mux) SetHandler(p ID, h inet.StreamHandler) {
87
// Handle reads the next name off the Stream, and calls a handler function
88
// This is done in its own goroutine, to avoid blocking the caller.
89
func (m *Mux) Handle(s inet.Stream) {
90
-
91
- // Flow control and backpressure of Opening streams is broken.
92
- // I believe that spdystream has one set of workers that both send
93
- // data AND accept new streams (as it's just more data). there
94
- // is a problem where if the new stream handlers want to throttle,
95
- // they also eliminate the ability to read/write data, which makes
96
- // forward-progress impossible. Thus, throttling this function is
97
- // -- at this moment -- not the solution. Either spdystream must
98
- // change, or we must throttle another way.
99
- //
100
- // In light of this, we use a goroutine for now (otherwise the
101
- // spdy worker totally blocks, and we can't even read the protocol
102
- // header). The better route in the future is to use a worker pool.
90
go m.HandleSync(s)
91
}
92
@@ -114,6 +101,7 @@ func (m *Mux) HandleSync(s inet.Stream) {
101
err = fmt.Errorf("protocol mux error: %s", err)
102
log.Error(err)
103
log.Event(ctx, "muxError", lgbl.Error(err))
104
+ s.Close()
105
return
106
}
107
p2p/protocol/mux_test.go
+1
-1
@@ -4,7 +4,7 @@ import (
4
"bytes"
5
"testing"
6
7
- inet "github.com/jbenet/go-ipfs/p2p/net"
7
+ inet "github.com/jbenet/go-ipfs/p2p/net2"
8
)
9
10
var testCases = map[string]string{