Skip to content

Commit c2e85a0

Browse files
committed
make destroySoon noop after first call
1 parent 40ef455 commit c2e85a0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/net.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -793,23 +793,22 @@ function onReadableStreamEnd() {
793793
}
794794
}
795795

796-
797796
Socket.prototype.destroySoon = function() {
798-
if (this.writable)
799-
this.end();
797+
if (this.destroyingOnFinish) return;
798+
799+
if (this.writable) this.end();
800800

801-
if (this.writableFinished)
801+
if (this.writableFinished) {
802802
this.destroy();
803-
else if (!this._destroyingOnFinish) {
804-
this._destroyingOnFinish = true;
803+
} else {
804+
this.destroyingOnFinish = true;
805805
this.once('finish', () => {
806-
this._destroyingOnFinish = false;
806+
this.destroyingOnFinish = false;
807807
this.destroy();
808808
});
809809
}
810810
};
811811

812-
813812
Socket.prototype._destroy = function(exception, cb) {
814813
debug('destroy');
815814

0 commit comments

Comments
 (0)