2
0
mirror of https://github.com/soheilhy/cmux.git synced 2024-11-09 19:21:52 +08:00

Mux connections in parallel

This commit launches a go-routine for each accepted connection, to match
them in parallel.
This commit is contained in:
Soheil Hassas Yeganeh 2015-07-31 19:42:28 -04:00
parent fa65c0526e
commit 581432eab8

10
cmux.go
View File

@ -103,9 +103,14 @@ func (m *cMux) Serve() error {
continue
}
go m.serve(c)
}
}
func (m *cMux) serve(c net.Conn) {
muc := newMuxConn(c)
matched := false
outer:
outer:
for _, sl := range m.sls {
for _, s := range sl.ss {
matched = s(muc.sniffer())
@ -121,8 +126,7 @@ func (m *cMux) Serve() error {
c.Close()
err := ErrNotMatched{c: c}
if !m.handleErr(err) {
return err
}
m.root.Close()
}
}
}