2
0
mirror of https://github.com/soheilhy/cmux.git synced 2024-09-20 02:55:46 +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

View File

@ -103,6 +103,11 @@ func (m *cMux) Serve() error {
continue continue
} }
go m.serve(c)
}
}
func (m *cMux) serve(c net.Conn) {
muc := newMuxConn(c) muc := newMuxConn(c)
matched := false matched := false
outer: outer:
@ -121,8 +126,7 @@ func (m *cMux) Serve() error {
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()
}
} }
} }
} }