From d497ebbf9c7b5b66d355e9645b0ab0b2c61527b2 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 20 Jul 2018 23:27:40 -0400 Subject: 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 Reviewed-By: Wyatt Preul Reviewed-By: Matteo Collina --- lib/dgram.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'lib/dgram.js') 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) { -- cgit v1.2.3