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
11 changes: 11 additions & 0 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,17 @@ var VitalsMenuButton = GObject.registerClass({
if (/^network-(?!rx$|tx$)/.test(typeKey)) typeKey = 'network';
let key = '_' + typeKey + '_' + label.replace(' ', '_').toLowerCase() + '_';

// issue #557 - interface is gone, drop it rather than show its last reading
if (value == 'destroy') {
this._values.removeNetworkSensor(key, label, type.replace('network-', ''));
if (key in this._sensorMenuItems) {
this._sensorMenuItems[key].destroy();
delete this._sensorMenuItems[key];
}
this._removeHotItem(key);
return;
}

// if a sensor is disabled, gray it out
if (key in this._sensorMenuItems) {
this._sensorMenuItems[key].setSensitive((value!='disabled'));
Expand Down
21 changes: 21 additions & 0 deletions sensors.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export const Sensors = GObject.registerClass({

this.resetHistory();

// interfaces seen by the last network query, to spot the ones that go away
this._network_interfaces = [];

this._last_processor = { 'core': {}, 'speed': [] };

this._settingChangedSignals = [];
Expand Down Expand Up @@ -311,6 +314,24 @@ export const Sensors = GObject.registerClass({
let netbase = '/sys/class/net/';

new FileModule.File(netbase).list().then(interfaces => {
// 'lo' is always present, so an empty listing means the read failed
if (!interfaces.length) return;

// issue #557 - forget interfaces the kernel no longer has
for (let iface of this._network_interfaces) {
if (interfaces.includes(iface)) continue;

for (let direction of directions) {
if (iface == 'lo' && direction == 'rx') continue;

let name = iface + ((iface == 'lo')?'':' ' + direction);
let type = 'network' + ((iface=='lo')?'':'-' + direction);
this._returnValue(callback, name, 'destroy', type, 'storage');
}
}

this._network_interfaces = interfaces;

for (let iface of interfaces) {
for (let direction of directions) {
// lo tx and rx are the same
Expand Down
11 changes: 11 additions & 0 deletions values.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,17 @@ export const Values = GObject.registerClass({
return output;
}

// issue #557 - forget a removed interface, so its last counters stop being totalled
removeNetworkSensor(key, label, direction) {
for (let type of ['network', 'network-rx', 'network-tx'])
if (type in this._history) delete this._history[type][key];

delete this._networkSpeedOffset[key];

if (direction in this._networkSpeeds)
delete this._networkSpeeds[direction][label];
}

resetHistory(numGpus) {
// don't call this._history = {}, as we want to keep network-rx and network-tx
// otherwise network history statistics will start over
Expand Down