network: remove the vpn request when it's serviced

The native agent already forgets about the request at the point it's
serviced and the further attempt to use it (e.g. cancel it when the screen
is locked) will trigger an assertion failure:

  ** (gnome-shell:30862): CRITICAL **: shell_network_agent_respond: assertion 'request != NULL' failed

https://bugzilla.gnome.org/show_bug.cgi?id=789811
This commit is contained in:
Lubomir Rintel 2017-12-06 16:55:15 +01:00
parent d71af5e579
commit baacd216dd

View File

@ -8,6 +8,7 @@ const Lang = imports.lang;
const NM = imports.gi.NM; const NM = imports.gi.NM;
const Pango = imports.gi.Pango; const Pango = imports.gi.Pango;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Signals = imports.signals;
const St = imports.gi.St; const St = imports.gi.St;
const Config = imports.misc.config; const Config = imports.misc.config;
@ -413,7 +414,9 @@ var VPNRequestHandler = new Lang.Class({
if (this._destroyed) if (this._destroyed)
return; return;
GLib.source_remove(this._childWatch); this.emit('destroy');
if (this._childWatch)
GLib.source_remove(this._childWatch);
this._stdin.close(null); this._stdin.close(null);
// Stdout is closed when we finish reading from it // Stdout is closed when we finish reading from it
@ -540,6 +543,7 @@ var VPNRequestHandler = new Lang.Class({
logError(e, 'error while reading VPN plugin output keyfile'); logError(e, 'error while reading VPN plugin output keyfile');
this._agent.respond(this._requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR); this._agent.respond(this._requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR);
this.destroy();
return; return;
} }
} }
@ -550,6 +554,7 @@ var VPNRequestHandler = new Lang.Class({
this._shellDialog.open(global.get_current_time()); this._shellDialog.open(global.get_current_time());
} else { } else {
this._agent.respond(this._requestId, Shell.NetworkAgentResponse.CONFIRMED); this._agent.respond(this._requestId, Shell.NetworkAgentResponse.CONFIRMED);
this.destroy();
} }
}, },
@ -570,9 +575,11 @@ var VPNRequestHandler = new Lang.Class({
logError(e, 'internal error while writing connection to helper'); logError(e, 'internal error while writing connection to helper');
this._agent.respond(this._requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR); this._agent.respond(this._requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR);
this.destroy();
} }
}, },
}); });
Signals.addSignalMethods(VPNRequestHandler.prototype);
var NetworkAgent = new Lang.Class({ var NetworkAgent = new Lang.Class({
Name: 'NetworkAgent', Name: 'NetworkAgent',
@ -740,7 +747,11 @@ var NetworkAgent = new Lang.Class({
return; return;
} }
this._vpnRequests[requestId] = new VPNRequestHandler(this._native, requestId, binary, serviceType, connection, hints, flags); let vpnRequest = new VPNRequestHandler(this._native, requestId, binary, serviceType, connection, hints, flags);
vpnRequest.connect('destroy', Lang.bind(this, function() {
delete this._vpnRequests[requestId];
}));
this._vpnRequests[requestId] = vpnRequest;
}, },
_buildVPNServiceCache: function() { _buildVPNServiceCache: function() {