peer: fix race condition - open emitted after peer.close().

This commit is contained in:
Christopher Jeffrey 2016-11-02 15:19:02 -07:00
parent cc58b507eb
commit 889f796748
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -290,6 +290,12 @@ Peer.prototype.open = co(function* open() {
return;
}
// The peer may have been killed before
// the handshake finished. In this case,
// do not emit `open`.
if (this.destroyed)
return;
// Finally we can let the pool know
// that this peer is ready to go.
this.emit('open');