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>
This commit is contained in:
parent
c4de500c87
commit
d497ebbf9c
34
lib/dgram.js
34
lib/dgram.js
@ -199,7 +199,7 @@ function bufferSize(self, size, buffer) {
|
|||||||
Socket.prototype.bind = function(port_, address_ /* , callback */) {
|
Socket.prototype.bind = function(port_, address_ /* , callback */) {
|
||||||
let port = port_;
|
let port = port_;
|
||||||
|
|
||||||
this._healthCheck();
|
healthCheck(this);
|
||||||
|
|
||||||
if (this._bindState !== BIND_STATE_UNBOUND)
|
if (this._bindState !== BIND_STATE_UNBOUND)
|
||||||
throw new ERR_SOCKET_ALREADY_BOUND();
|
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);
|
throw new ERR_INVALID_ARG_TYPE('address', ['string', 'falsy'], address);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._healthCheck();
|
healthCheck(this);
|
||||||
|
|
||||||
if (this._bindState === BIND_STATE_UNBOUND)
|
if (this._bindState === BIND_STATE_UNBOUND)
|
||||||
this.bind({ port: 0, exclusive: true }, null);
|
this.bind({ port: 0, exclusive: true }, null);
|
||||||
@ -525,8 +525,8 @@ Socket.prototype.close = function(callback) {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._healthCheck();
|
healthCheck(this);
|
||||||
this._stopReceiving();
|
stopReceiving(this);
|
||||||
this._handle.close();
|
this._handle.close();
|
||||||
this._handle = null;
|
this._handle = null;
|
||||||
defaultTriggerAsyncIdScope(this[async_id_symbol],
|
defaultTriggerAsyncIdScope(this[async_id_symbol],
|
||||||
@ -544,7 +544,7 @@ function socketCloseNT(self) {
|
|||||||
|
|
||||||
|
|
||||||
Socket.prototype.address = function() {
|
Socket.prototype.address = function() {
|
||||||
this._healthCheck();
|
healthCheck(this);
|
||||||
|
|
||||||
var out = {};
|
var out = {};
|
||||||
var err = this._handle.getsockname(out);
|
var err = this._handle.getsockname(out);
|
||||||
@ -603,7 +603,7 @@ Socket.prototype.setMulticastLoopback = function(arg) {
|
|||||||
|
|
||||||
|
|
||||||
Socket.prototype.setMulticastInterface = function(interfaceAddress) {
|
Socket.prototype.setMulticastInterface = function(interfaceAddress) {
|
||||||
this._healthCheck();
|
healthCheck(this);
|
||||||
|
|
||||||
if (typeof interfaceAddress !== 'string') {
|
if (typeof interfaceAddress !== 'string') {
|
||||||
throw new ERR_INVALID_ARG_TYPE(
|
throw new ERR_INVALID_ARG_TYPE(
|
||||||
@ -618,7 +618,7 @@ Socket.prototype.setMulticastInterface = function(interfaceAddress) {
|
|||||||
|
|
||||||
Socket.prototype.addMembership = function(multicastAddress,
|
Socket.prototype.addMembership = function(multicastAddress,
|
||||||
interfaceAddress) {
|
interfaceAddress) {
|
||||||
this._healthCheck();
|
healthCheck(this);
|
||||||
|
|
||||||
if (!multicastAddress) {
|
if (!multicastAddress) {
|
||||||
throw new ERR_MISSING_ARGS('multicastAddress');
|
throw new ERR_MISSING_ARGS('multicastAddress');
|
||||||
@ -633,7 +633,7 @@ Socket.prototype.addMembership = function(multicastAddress,
|
|||||||
|
|
||||||
Socket.prototype.dropMembership = function(multicastAddress,
|
Socket.prototype.dropMembership = function(multicastAddress,
|
||||||
interfaceAddress) {
|
interfaceAddress) {
|
||||||
this._healthCheck();
|
healthCheck(this);
|
||||||
|
|
||||||
if (!multicastAddress) {
|
if (!multicastAddress) {
|
||||||
throw new ERR_MISSING_ARGS('multicastAddress');
|
throw new ERR_MISSING_ARGS('multicastAddress');
|
||||||
@ -646,22 +646,22 @@ Socket.prototype.dropMembership = function(multicastAddress,
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Socket.prototype._healthCheck = function() {
|
function healthCheck(socket) {
|
||||||
if (!this._handle) {
|
if (!socket._handle) {
|
||||||
// Error message from dgram_legacy.js.
|
// Error message from dgram_legacy.js.
|
||||||
throw new ERR_SOCKET_DGRAM_NOT_RUNNING();
|
throw new ERR_SOCKET_DGRAM_NOT_RUNNING();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
Socket.prototype._stopReceiving = function() {
|
function stopReceiving(socket) {
|
||||||
if (!this._receiving)
|
if (!socket._receiving)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._handle.recvStop();
|
socket._handle.recvStop();
|
||||||
this._receiving = false;
|
socket._receiving = false;
|
||||||
this.fd = null; // compatibility hack
|
socket.fd = null; // compatibility hack
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
function onMessage(nread, handle, buf, rinfo) {
|
function onMessage(nread, handle, buf, rinfo) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user