Commit 4e3fad33 authored by Ray Strode's avatar Ray Strode

daemon: call reload_users after timeout on passwd/shadow changes

Often the two files are changed in concert, so it makes sense to
wait a bit before doing a heavy reload operation.

Suggested by Vincent.

https://bugs.freedesktop.org/show_bug.cgi?id=39413
parent 07ea415a
...@@ -491,6 +491,19 @@ reload_autologin_timeout (Daemon *daemon) ...@@ -491,6 +491,19 @@ reload_autologin_timeout (Daemon *daemon)
return FALSE; return FALSE;
} }
static void
queue_reload_users_soon (Daemon *daemon)
{
if (daemon->priv->reload_id > 0) {
return;
}
/* we wait half a second or so in case /etc/passwd and
* /etc/shadow are changed at the same time, or repeatedly.
*/
daemon->priv->reload_id = g_timeout_add (500, (GSourceFunc)reload_users_timeout, daemon);
}
static void static void
queue_reload_users (Daemon *daemon) queue_reload_users (Daemon *daemon)
{ {
...@@ -523,7 +536,7 @@ on_passwd_monitor_changed (GFileMonitor *monitor, ...@@ -523,7 +536,7 @@ on_passwd_monitor_changed (GFileMonitor *monitor,
return; return;
} }
reload_users (daemon); queue_reload_users_soon (daemon);
} }
static void static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment