2
0
mirror of https://github.com/soheilhy/cmux.git synced 2026-09-03 01:04:32 +08:00
go/src/github.com/soheilhy/cmux/cmux.go:127:13	c.Close()
go/src/github.com/soheilhy/cmux/cmux.go:134:9	c.Close()
go/src/github.com/soheilhy/cmux/cmux.go:137:15	m.root.Close()
go/src/github.com/soheilhy/cmux/cmux_test.go:43:9	s.Serve(l)
go/src/github.com/soheilhy/cmux/cmux_test.go:52:20	defer r.Body.Close()
go/src/github.com/soheilhy/cmux/cmux_test.go:72:12	s.Register(TestRPCRcvr{})
go/src/github.com/soheilhy/cmux/cmux_test.go:103:15	defer l.Close()
go/src/github.com/soheilhy/cmux/cmux_test.go:109:15	go muxl.Serve()
go/src/github.com/soheilhy/cmux/cmux_test.go:116:20	defer r.Body.Close()
go/src/github.com/soheilhy/cmux/cmux_test.go:125:15	defer l.Close()
go/src/github.com/soheilhy/cmux/cmux_test.go:133:15	go muxl.Serve()
go/src/github.com/soheilhy/cmux/cmux_test.go:141:15	defer l.Close()
go/src/github.com/soheilhy/cmux/cmux_test.go:147:15	go muxl.Serve()
go/src/github.com/soheilhy/cmux/example_recursive_test.go:27:9	s.Serve(l)
go/src/github.com/soheilhy/cmux/example_recursive_test.go:56:12	s.Register(&RecursiveRPCRcvr{})
go/src/github.com/soheilhy/cmux/example_recursive_test.go:88:15	go tlsm.Serve()
go/src/github.com/soheilhy/cmux/example_recursive_test.go:89:12	tcpm.Serve()
go/src/github.com/soheilhy/cmux/example_test.go:30:9	s.Serve(l)
go/src/github.com/soheilhy/cmux/example_test.go:34:9	io.Copy(ws, ws)
go/src/github.com/soheilhy/cmux/example_test.go:41:9	s.Serve(l)
go/src/github.com/soheilhy/cmux/example_test.go:53:12	s.Register(&ExampleRPCRcvr{})
go/src/github.com/soheilhy/cmux/example_test.go:68:13	grpcs.Serve(l)
go/src/github.com/soheilhy/cmux/example_test.go:97:9	m.Serve()
go/src/github.com/soheilhy/cmux/example_tls_test.go:24:9	s.Serve(l)
go/src/github.com/soheilhy/cmux/example_tls_test.go:69:9	m.Serve()
go/src/github.com/soheilhy/cmux/matchers.go:151:14	hdec.Write(f.HeaderBlockFragment())
This commit is contained in:
Tamir Duberstein
2016-01-07 10:15:03 -05:00
committed by Soheil Hassas Yeganeh
parent ec462e9c0e
commit 92a63c4fce
7 changed files with 127 additions and 37 deletions

View File

@@ -8,6 +8,7 @@ import (
"net"
"net/http"
"net/rpc"
"strings"
"github.com/soheilhy/cmux"
)
@@ -24,7 +25,9 @@ func recursiveServeHTTP(l net.Listener) {
s := &http.Server{
Handler: &recursiveHTTPHandler{},
}
s.Serve(l)
if err := s.Serve(l); err != cmux.ErrListenerClosed {
panic(err)
}
}
func tlsListener(l net.Listener) net.Listener {
@@ -53,8 +56,19 @@ func (r *RecursiveRPCRcvr) Cube(i int, j *int) error {
func recursiveServeRPC(l net.Listener) {
s := rpc.NewServer()
s.Register(&RecursiveRPCRcvr{})
s.Accept(l)
if err := s.Register(&RecursiveRPCRcvr{}); err != nil {
panic(err)
}
for {
conn, err := l.Accept()
if err != nil {
if err != cmux.ErrListenerClosed {
panic(err)
}
return
}
go s.ServeConn(conn)
}
}
// This is an example for serving HTTP, HTTPS, and GoRPC/TLS on the same port.
@@ -80,11 +94,16 @@ func Example_recursiveCmux() {
tlsm := cmux.New(tlsl)
httpsl := tlsm.Match(cmux.HTTP1Fast())
gorpcl := tlsm.Match(cmux.Any())
go recursiveServeHTTP(httpl)
go recursiveServeHTTP(httpsl)
go recursiveServeRPC(gorpcl)
go tlsm.Serve()
tcpm.Serve()
go func() {
if err := tlsm.Serve(); err != cmux.ErrListenerClosed {
panic(err)
}
}()
if err := tcpm.Serve(); !strings.Contains(err.Error(), "use of closed network connection") {
panic(err)
}
}