aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnatoli Papirovski <apapirovski@mac.com>2017-10-25 09:26:20 -0400
committercjihrig <cjihrig@gmail.com>2017-10-25 14:48:30 -0400
commitcecbb595d5c4ea97264092abf2ade16b54a945fd (patch)
tree942fea48b889e12a37403da25137900e024ff5e0 /lib
parenta78327f48be4266e250ad4c2170a0f263b47bc5f (diff)
downloadandroid-node-v8-cecbb595d5c4ea97264092abf2ade16b54a945fd.tar.gz
android-node-v8-cecbb595d5c4ea97264092abf2ade16b54a945fd.tar.bz2
android-node-v8-cecbb595d5c4ea97264092abf2ade16b54a945fd.zip
net: fix timeout with null handle
This commit handles the case where _onTimeout is called with a null handle. Refs: https://github.com/nodejs/node/pull/15791 Fixes: https://github.com/nodejs/node/issues/16484 PR-URL: https://github.com/nodejs/node/pull/16489 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/net.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/net.js b/lib/net.js
index 5356357fc9..facf5d0d6b 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -397,13 +397,15 @@ Socket.prototype.setTimeout = function(msecs, callback) {
Socket.prototype._onTimeout = function() {
- // `.prevWriteQueueSize` !== `.updateWriteQueueSize()` means there is
- // an active write in progress, so we suppress the timeout.
- const prevWriteQueueSize = this._handle.writeQueueSize;
- if (prevWriteQueueSize > 0 &&
- prevWriteQueueSize !== this._handle.updateWriteQueueSize()) {
- this._unrefTimer();
- return;
+ if (this._handle) {
+ // `.prevWriteQueueSize` !== `.updateWriteQueueSize()` means there is
+ // an active write in progress, so we suppress the timeout.
+ const prevWriteQueueSize = this._handle.writeQueueSize;
+ if (prevWriteQueueSize > 0 &&
+ prevWriteQueueSize !== this._handle.updateWriteQueueSize()) {
+ this._unrefTimer();
+ return;
+ }
}
debug('_onTimeout');
this.emit('timeout');