diff --git a/Changes.md b/Changes.md index 32b74b8ae..55d8fab9e 100644 --- a/Changes.md +++ b/Changes.md @@ -4,6 +4,10 @@ This file is a manually maintained list of changes for each release. Feel free to add your changes here when sending pull requests. Also send corrections if you spot any mistakes. +## HEAD + +* Fix holding first closure for lifetime of connection #1785 + ## v2.14.0 (2017-07-25) * Add new Amazon RDS ap-south-1 certificate CA to Amazon RDS SSL profile #1780 diff --git a/lib/protocol/Protocol.js b/lib/protocol/Protocol.js index 69032d849..9224936a3 100644 --- a/lib/protocol/Protocol.js +++ b/lib/protocol/Protocol.js @@ -21,7 +21,7 @@ function Protocol(options) { this._callback = null; this._fatalError = null; this._quitSequence = null; - this._handshakeSequence = null; + this._handshake = false; this._handshaked = false; this._ended = false; this._destroyed = false; @@ -49,7 +49,11 @@ Protocol.prototype.handshake = function handshake(options, callback) { options = options || {}; options.config = this._config; - return this._handshakeSequence = this._enqueue(new Sequences.Handshake(options, callback)); + var sequence = this._enqueue(new Sequences.Handshake(options, callback)); + + this._handshake = true; + + return sequence; }; Protocol.prototype.query = function query(options, callback) { @@ -202,7 +206,7 @@ Protocol.prototype._validateEnqueue = function _validateEnqueue(sequence) { } else if (this._destroyed) { err = new Error(prefix + ' after being destroyed.'); err.code = 'PROTOCOL_ENQUEUE_AFTER_DESTROY'; - } else if (this._handshakeSequence && sequence.constructor === Sequences.Handshake) { + } else if ((this._handshake || this._handshaked) && sequence.constructor === Sequences.Handshake) { err = new Error(prefix + ' after already enqueuing a Handshake.'); err.code = 'PROTOCOL_ENQUEUE_HANDSHAKE_TWICE'; } else {