mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
TLS: Make _cycle reentrant.
This commit is contained in:
parent
89bfa419a5
commit
19b4c27ebf
16
lib/tls.js
16
lib/tls.js
@ -69,7 +69,9 @@ CryptoStream.prototype.write = function(data /* , encoding, cb */) {
|
||||
this._pending.push(data);
|
||||
this._pendingCallbacks.push(cb);
|
||||
|
||||
this.pair._writeCalled = true;
|
||||
this.pair._cycle();
|
||||
|
||||
return this._writeState;
|
||||
};
|
||||
|
||||
@ -507,6 +509,11 @@ SecurePair.prototype._cycle = function() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make this function reentrant.
|
||||
if (this._cycleLock) return;
|
||||
this._cycleLock = true;
|
||||
this._writeCalled = false;
|
||||
|
||||
var established = this._secureEstablished;
|
||||
|
||||
this.encrypted._pull();
|
||||
@ -514,8 +521,15 @@ SecurePair.prototype._cycle = function() {
|
||||
this.cleartext._push();
|
||||
this.encrypted._push();
|
||||
|
||||
if (!established && this._secureEstablished) {
|
||||
this._cycleLock = false;
|
||||
|
||||
if (this._done) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((!established && this._secureEstablished) || this._writeCalled) {
|
||||
// If we were not established but now we are, let's cycle again.
|
||||
// Or if there is some data to write...
|
||||
this._cycle();
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user