diff options
author | cjihrig <cjihrig@gmail.com> | 2018-07-20 23:27:40 -0400 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2018-07-28 00:35:08 -0400 |
commit | d497ebbf9c7b5b66d355e9645b0ab0b2c61527b2 (patch) | |
tree | 5e3160fbfe6aeb576b1598f49124d11bf4975d3f /lib/dgram.js | |
parent | c4de500c8785511eb18285a74fb9173ee06032e7 (diff) | |
download | android-node-v8-d497ebbf9c7b5b66d355e9645b0ab0b2c61527b2.tar.gz android-node-v8-d497ebbf9c7b5b66d355e9645b0ab0b2c61527b2.tar.bz2 android-node-v8-d497ebbf9c7b5b66d355e9645b0ab0b2c61527b2.zip |
dgram: hide _healthCheck() and _stopReceiving()
These methods are private APIs of dgram sockets, but do not
need to be exposed via the Socket prototype.
PR-URL: https://github.com/nodejs/node/pull/21923
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib/dgram.js')
-rw-r--r-- | lib/dgram.js | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/dgram.js b/lib/dgram.js index f3454ffc07..dc664ca2c4 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -199,7 +199,7 @@ function bufferSize(self, size, buffer) { Socket.prototype.bind = function(port_, address_ /* , callback */) { let port = port_; - this._healthCheck(); + healthCheck(this); if (this._bindState !== BIND_STATE_UNBOUND) throw new ERR_SOCKET_ALREADY_BOUND(); @@ -444,7 +444,7 @@ Socket.prototype.send = function(buffer, throw new ERR_INVALID_ARG_TYPE('address', ['string', 'falsy'], address); } - this._healthCheck(); + healthCheck(this); if (this._bindState === BIND_STATE_UNBOUND) this.bind({ port: 0, exclusive: true }, null); @@ -525,8 +525,8 @@ Socket.prototype.close = function(callback) { return this; } - this._healthCheck(); - this._stopReceiving(); + healthCheck(this); + stopReceiving(this); this._handle.close(); this._handle = null; defaultTriggerAsyncIdScope(this[async_id_symbol], @@ -544,7 +544,7 @@ function socketCloseNT(self) { Socket.prototype.address = function() { - this._healthCheck(); + healthCheck(this); var out = {}; var err = this._handle.getsockname(out); @@ -603,7 +603,7 @@ Socket.prototype.setMulticastLoopback = function(arg) { Socket.prototype.setMulticastInterface = function(interfaceAddress) { - this._healthCheck(); + healthCheck(this); if (typeof interfaceAddress !== 'string') { throw new ERR_INVALID_ARG_TYPE( @@ -618,7 +618,7 @@ Socket.prototype.setMulticastInterface = function(interfaceAddress) { Socket.prototype.addMembership = function(multicastAddress, interfaceAddress) { - this._healthCheck(); + healthCheck(this); if (!multicastAddress) { throw new ERR_MISSING_ARGS('multicastAddress'); @@ -633,7 +633,7 @@ Socket.prototype.addMembership = function(multicastAddress, Socket.prototype.dropMembership = function(multicastAddress, interfaceAddress) { - this._healthCheck(); + healthCheck(this); if (!multicastAddress) { throw new ERR_MISSING_ARGS('multicastAddress'); @@ -646,22 +646,22 @@ Socket.prototype.dropMembership = function(multicastAddress, }; -Socket.prototype._healthCheck = function() { - if (!this._handle) { +function healthCheck(socket) { + if (!socket._handle) { // Error message from dgram_legacy.js. throw new ERR_SOCKET_DGRAM_NOT_RUNNING(); } -}; +} -Socket.prototype._stopReceiving = function() { - if (!this._receiving) +function stopReceiving(socket) { + if (!socket._receiving) return; - this._handle.recvStop(); - this._receiving = false; - this.fd = null; // compatibility hack -}; + socket._handle.recvStop(); + socket._receiving = false; + socket.fd = null; // compatibility hack +} function onMessage(nread, handle, buf, rinfo) { |