Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/NetworkInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,15 @@ NetworkInterface.prototype.stop = function () {
this._sockets = [];
this._buffers = [];

var intf = this;

// Remove any entries from active interfaces.
Object.keys(activeInterfaces).forEach(function (name) {
if (activeInterfaces[name] === intf) {
delete activeInterfaces[name];
}
});

debug('Done.');
};

Expand Down
9 changes: 9 additions & 0 deletions src/NetworkInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,15 @@ NetworkInterface.prototype.stop = function() {
this._sockets = [];
this._buffers = [];

const intf = this;

// Remove any entries from active interfaces.
Object.keys(activeInterfaces).forEach((name) => {
if (activeInterfaces[name] === intf) {
delete activeInterfaces[name];
}
});

debug('Done.');
};

Expand Down
9 changes: 9 additions & 0 deletions test/tests/NetworkInterface.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,15 @@ describe('NetworkInterface', function() {
intf._sockets = [socket];
intf.stop();
});

it.only('should remove interface from active interfaces cache', function() {
const intf = new NetworkInterface.get();

intf.stop();
const newIntf = new NetworkInterface.get();

expect(newIntf).to.not.equal(intf)
});
});

});