update go-peerstream dependency
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Jeromy committed
Oct 11, 2015 at 20:22 UTC
31d7f030813c801c0354a77018f1e6007281b94b
2 files changed
+12
-1
Godeps/Godeps.json
+1
-1
@@ -196,7 +196,7 @@
196
},
197
{
198
"ImportPath": "github.com/jbenet/go-peerstream",
199
- "Rev": "cfdc29a19c1a209d548670f5c33c5cda2e040143"
199
+ "Rev": "f90119e97e8be7b2bdd5e598067b0dc44df63381"
200
},
201
{
202
"ImportPath": "github.com/jbenet/go-random",
Godeps/_workspace/src/github.com/jbenet/go-peerstream/conn.go
+11
@@ -44,6 +44,9 @@ type Conn struct {
44
45
streams map[*Stream]struct{}
46
streamLock sync.RWMutex
47
+
48
+ closed bool
49
+ closeLock sync.Mutex
50
}
51
52
func newConn(nconn net.Conn, tconn smux.Conn, s *Swarm) *Conn {
@@ -114,6 +117,14 @@ func (c *Conn) Streams() []*Stream {
117
118
// Close closes this connection
119
func (c *Conn) Close() error {
120
+ c.closeLock.Lock()
121
+ defer c.closeLock.Unlock()
122
+
123
+ if c.closed {
124
+ return nil
125
+ }
126
+ c.closed = true
127
+
128
// close streams
129
streams := c.Streams()
130
for _, s := range streams {