mirror of
https://github.com/soheilhy/cmux.git
synced 2025-01-19 03:06:07 +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
38
cmux.go
38
cmux.go
@ -103,26 +103,30 @@ func (m *cMux) Serve() error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
muc := newMuxConn(c)
|
go m.serve(c)
|
||||||
matched := false
|
}
|
||||||
outer:
|
}
|
||||||
for _, sl := range m.sls {
|
|
||||||
for _, s := range sl.ss {
|
func (m *cMux) serve(c net.Conn) {
|
||||||
matched = s(muc.sniffer())
|
muc := newMuxConn(c)
|
||||||
muc.reset()
|
matched := false
|
||||||
if matched {
|
outer:
|
||||||
sl.l.cch <- muc
|
for _, sl := range m.sls {
|
||||||
break outer
|
for _, s := range sl.ss {
|
||||||
}
|
matched = s(muc.sniffer())
|
||||||
|
muc.reset()
|
||||||
|
if matched {
|
||||||
|
sl.l.cch <- muc
|
||||||
|
break outer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !matched {
|
if !matched {
|
||||||
c.Close()
|
c.Close()
|
||||||
err := ErrNotMatched{c: c}
|
err := ErrNotMatched{c: c}
|
||||||
if !m.handleErr(err) {
|
if !m.handleErr(err) {
|
||||||
return err
|
m.root.Close()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user