提交 129eca0d 作者: Juan Batiz-Benet

multiconn: close fanIn + error

上级 5341379f
......@@ -2,6 +2,7 @@ package conn
import (
"errors"
"fmt"
"sync"
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
......@@ -179,6 +180,7 @@ func (c *MultiConn) close() error {
// close underlying connections
CloseConns(conns...)
close(c.fanIn)
return nil
}
......@@ -266,7 +268,10 @@ func (c *MultiConn) Write(buf []byte) (int, error) {
// ReadMsg reads data, net.Conn style
func (c *MultiConn) ReadMsg() ([]byte, error) {
next := <-c.fanIn
next, ok := <-c.fanIn
if !ok {
return nil, fmt.Errorf("multiconn closed")
}
return next, nil
}
......@@ -281,6 +286,7 @@ func (c *MultiConn) WriteMsg(buf []byte) error {
// ReleaseMsg releases a buffer
func (c *MultiConn) ReleaseMsg(m []byte) {
// here, we dont know where it came from. hm.
for _, c := range c.getConns() {
c.ReleaseMsg(m)
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论