Skip to content

Commit b5b7438

Browse files
cjihrigtargos
authored andcommitted
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: #21923 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Wyatt Preul <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent e0336b2 commit b5b7438

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

lib/dgram.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ function bufferSize(self, size, buffer) {
199199
Socket.prototype.bind = function(port_, address_ /* , callback */) {
200200
let port = port_;
201201

202-
this._healthCheck();
202+
healthCheck(this);
203203

204204
if (this._bindState !== BIND_STATE_UNBOUND)
205205
throw new ERR_SOCKET_ALREADY_BOUND();
@@ -444,7 +444,7 @@ Socket.prototype.send = function(buffer,
444444
throw new ERR_INVALID_ARG_TYPE('address', ['string', 'falsy'], address);
445445
}
446446

447-
this._healthCheck();
447+
healthCheck(this);
448448

449449
if (this._bindState === BIND_STATE_UNBOUND)
450450
this.bind({ port: 0, exclusive: true }, null);
@@ -525,8 +525,8 @@ Socket.prototype.close = function(callback) {
525525
return this;
526526
}
527527

528-
this._healthCheck();
529-
this._stopReceiving();
528+
healthCheck(this);
529+
stopReceiving(this);
530530
this._handle.close();
531531
this._handle = null;
532532
defaultTriggerAsyncIdScope(this[async_id_symbol],
@@ -544,7 +544,7 @@ function socketCloseNT(self) {
544544

545545

546546
Socket.prototype.address = function() {
547-
this._healthCheck();
547+
healthCheck(this);
548548

549549
var out = {};
550550
var err = this._handle.getsockname(out);
@@ -603,7 +603,7 @@ Socket.prototype.setMulticastLoopback = function(arg) {
603603

604604

605605
Socket.prototype.setMulticastInterface = function(interfaceAddress) {
606-
this._healthCheck();
606+
healthCheck(this);
607607

608608
if (typeof interfaceAddress !== 'string') {
609609
throw new ERR_INVALID_ARG_TYPE(
@@ -618,7 +618,7 @@ Socket.prototype.setMulticastInterface = function(interfaceAddress) {
618618

619619
Socket.prototype.addMembership = function(multicastAddress,
620620
interfaceAddress) {
621-
this._healthCheck();
621+
healthCheck(this);
622622

623623
if (!multicastAddress) {
624624
throw new ERR_MISSING_ARGS('multicastAddress');
@@ -633,7 +633,7 @@ Socket.prototype.addMembership = function(multicastAddress,
633633

634634
Socket.prototype.dropMembership = function(multicastAddress,
635635
interfaceAddress) {
636-
this._healthCheck();
636+
healthCheck(this);
637637

638638
if (!multicastAddress) {
639639
throw new ERR_MISSING_ARGS('multicastAddress');
@@ -646,22 +646,22 @@ Socket.prototype.dropMembership = function(multicastAddress,
646646
};
647647

648648

649-
Socket.prototype._healthCheck = function() {
650-
if (!this._handle) {
649+
function healthCheck(socket) {
650+
if (!socket._handle) {
651651
// Error message from dgram_legacy.js.
652652
throw new ERR_SOCKET_DGRAM_NOT_RUNNING();
653653
}
654-
};
654+
}
655655

656656

657-
Socket.prototype._stopReceiving = function() {
658-
if (!this._receiving)
657+
function stopReceiving(socket) {
658+
if (!socket._receiving)
659659
return;
660660

661-
this._handle.recvStop();
662-
this._receiving = false;
663-
this.fd = null; // compatibility hack
664-
};
661+
socket._handle.recvStop();
662+
socket._receiving = false;
663+
socket.fd = null; // compatibility hack
664+
}
665665

666666

667667
function onMessage(nread, handle, buf, rinfo) {

0 commit comments

Comments
 (0)