mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-22 12:40:07 +01:00
libnm/libnm-glib: don't quit in the middle of asking for secrets (bgo #752237)
If the VPN plugin terminated and the user started it again, then the quit timer will still be running and it sometimes happens that the VPN plugin will quit while the UI is asking the user for secrets. That's not very nice, so don't do that. Reproducer: while connect to the VPN, suspend your laptop. Then resume it, and immediately re-start the VPN connection. Watch the secrets dialog disappear within a very short time. https://bugzilla.gnome.org/show_bug.cgi?id=752237
This commit is contained in:
parent
aa7ab4b056
commit
3272ff6fc5
2 changed files with 34 additions and 6 deletions
|
|
@ -279,6 +279,17 @@ quit_timer_expired (gpointer data)
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
schedule_quit_timer (NMVPNPlugin *self)
|
||||||
|
{
|
||||||
|
NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (self);
|
||||||
|
|
||||||
|
nm_clear_g_source (&priv->quit_timer);
|
||||||
|
priv->quit_timer = g_timeout_add_seconds (NM_VPN_PLUGIN_QUIT_TIMER,
|
||||||
|
quit_timer_expired,
|
||||||
|
self);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fail_stop (gpointer data)
|
fail_stop (gpointer data)
|
||||||
{
|
{
|
||||||
|
|
@ -539,6 +550,11 @@ impl_vpn_plugin_need_secrets (NMVPNPlugin *plugin,
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
if (needed) {
|
if (needed) {
|
||||||
|
/* Push back the quit timer so the VPN plugin doesn't quit in the
|
||||||
|
* middle of asking the user for secrets.
|
||||||
|
*/
|
||||||
|
schedule_quit_timer (plugin);
|
||||||
|
|
||||||
g_assert (sn);
|
g_assert (sn);
|
||||||
*setting_name = g_strdup (sn);
|
*setting_name = g_strdup (sn);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -889,9 +905,7 @@ state_changed (NMVPNPlugin *plugin, NMVPNServiceState state)
|
||||||
nm_clear_g_source (&priv->fail_stop_id);
|
nm_clear_g_source (&priv->fail_stop_id);
|
||||||
break;
|
break;
|
||||||
case NM_VPN_SERVICE_STATE_STOPPED:
|
case NM_VPN_SERVICE_STATE_STOPPED:
|
||||||
priv->quit_timer = g_timeout_add_seconds (NM_VPN_PLUGIN_QUIT_TIMER,
|
schedule_quit_timer (plugin);
|
||||||
quit_timer_expired,
|
|
||||||
plugin);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* Clean up all timers we might have set up. */
|
/* Clean up all timers we might have set up. */
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,17 @@ quit_timer_expired (gpointer data)
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
schedule_quit_timer (NMVpnPluginOld *self)
|
||||||
|
{
|
||||||
|
NMVpnPluginOldPrivate *priv = NM_VPN_PLUGIN_OLD_GET_PRIVATE (self);
|
||||||
|
|
||||||
|
nm_clear_g_source (&priv->quit_timer);
|
||||||
|
priv->quit_timer = g_timeout_add_seconds (NM_VPN_PLUGIN_OLD_QUIT_TIMER,
|
||||||
|
quit_timer_expired,
|
||||||
|
self);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fail_stop (gpointer data)
|
fail_stop (gpointer data)
|
||||||
{
|
{
|
||||||
|
|
@ -501,6 +512,11 @@ impl_vpn_plugin_old_need_secrets (NMVpnPluginOld *plugin,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needed) {
|
if (needed) {
|
||||||
|
/* Push back the quit timer so the VPN plugin doesn't quit in the
|
||||||
|
* middle of asking the user for secrets.
|
||||||
|
*/
|
||||||
|
schedule_quit_timer (plugin);
|
||||||
|
|
||||||
g_assert (setting_name);
|
g_assert (setting_name);
|
||||||
g_dbus_method_invocation_return_value (context,
|
g_dbus_method_invocation_return_value (context,
|
||||||
g_variant_new ("(s)", setting_name));
|
g_variant_new ("(s)", setting_name));
|
||||||
|
|
@ -1030,9 +1046,7 @@ state_changed (NMVpnPluginOld *plugin, NMVpnServiceState state)
|
||||||
nm_clear_g_source (&priv->fail_stop_id);
|
nm_clear_g_source (&priv->fail_stop_id);
|
||||||
break;
|
break;
|
||||||
case NM_VPN_SERVICE_STATE_STOPPED:
|
case NM_VPN_SERVICE_STATE_STOPPED:
|
||||||
priv->quit_timer = g_timeout_add_seconds (NM_VPN_PLUGIN_OLD_QUIT_TIMER,
|
schedule_quit_timer (plugin);
|
||||||
quit_timer_expired,
|
|
||||||
plugin);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* Clean up all timers we might have set up. */
|
/* Clean up all timers we might have set up. */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue