Skip to content

Commit

Permalink
Fix holding first closure for lifetime of connection
Browse files Browse the repository at this point in the history
fixes #1785
  • Loading branch information
dougwilson committed Jul 31, 2017
1 parent c4f870c commit 0457404
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Changes.md
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions lib/protocol/Protocol.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0457404

Please sign in to comment.