提交 69b1ce42 作者: Juan Batiz-Benet 提交者: Brian Tiger Chow

nil muxer

上级 dc0fbfd3
...@@ -41,6 +41,10 @@ func (m *Muxer) GetPipe() *msg.Pipe { ...@@ -41,6 +41,10 @@ func (m *Muxer) GetPipe() *msg.Pipe {
// Start kicks off the Muxer goroutines. // Start kicks off the Muxer goroutines.
func (m *Muxer) Start(ctx context.Context) error { func (m *Muxer) Start(ctx context.Context) error {
if m == nil {
panic("nix muxer")
}
if m.cancel != nil { if m.cancel != nil {
return errors.New("Muxer already started.") return errors.New("Muxer already started.")
} }
...@@ -75,7 +79,12 @@ func (m *Muxer) AddProtocol(p Protocol, pid ProtocolID) error { ...@@ -75,7 +79,12 @@ func (m *Muxer) AddProtocol(p Protocol, pid ProtocolID) error {
// handleIncoming consumes the messages on the m.Incoming channel and // handleIncoming consumes the messages on the m.Incoming channel and
// routes them appropriately (to the protocols). // routes them appropriately (to the protocols).
func (m *Muxer) handleIncomingMessages(ctx context.Context) { func (m *Muxer) handleIncomingMessages(ctx context.Context) {
for { for {
if m == nil {
panic("nix muxer")
}
select { select {
case msg := <-m.Incoming: case msg := <-m.Incoming:
go m.handleIncomingMessage(ctx, msg) go m.handleIncomingMessage(ctx, msg)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论