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:
parent
fa65c0526e
commit
581432eab8
10
cmux.go
10
cmux.go
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user