mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-12 03:37:59 +08:00
multiconn: close fanIn + error
This commit is contained in:
parent
5341379f9d
commit
129eca0d82
@ -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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user