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
25 changes: 24 additions & 1 deletion src/daemon/rpmostreed-daemon.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,20 @@ on_idle_exit (void *data)
return FALSE;
}

void
reset_idle_exit_timer (GDBusConnection *connection, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name,
const gchar *signal_name, GVariant *parameters, gpointer user_data)
{
auto self = static_cast<RpmostreedDaemon *> (user_data);
if (self->idle_exit_source)
{
guint64 curtime = g_source_get_time (self->idle_exit_source);
const guint idle_exit_secs = self->idle_exit_timeout + g_random_int_range (0, 5);
g_source_set_ready_time (self->idle_exit_source, curtime + idle_exit_secs * G_USEC_PER_SEC);
}
}

static void
update_status (RpmostreedDaemon *self)
{
Expand All @@ -571,6 +585,12 @@ update_status (RpmostreedDaemon *self)
const guint n_clients = g_hash_table_size (self->bus_clients);
gboolean currently_idle = FALSE;

guint subscription_id;

subscription_id = g_dbus_connection_signal_subscribe (
self->connection, NULL, NULL, NULL, "/org/freedesktop/DBus", NULL, G_DBUS_SIGNAL_FLAGS_NONE,
reset_idle_exit_timer, g_object_ref (self), g_object_unref);

g_object_get (rpmostreed_sysroot_get (), "active-transaction", &active_txn, NULL);

if (active_txn)
Expand Down Expand Up @@ -618,7 +638,10 @@ update_status (RpmostreedDaemon *self)
guint64 curtime = g_source_get_time (self->idle_exit_source);
guint64 timeout_micros = readytime - curtime;
if (readytime < curtime)
timeout_micros = 0;
{
timeout_micros = 0;
g_dbus_connection_signal_unsubscribe (self->connection, subscription_id);
}

g_assert (currently_idle && self->idle_exit_source);
sd_notifyf (0, "STATUS=clients=%u; idle exit in %" G_GUINT64_FORMAT " seconds", n_clients,
Expand Down
4 changes: 4 additions & 0 deletions src/daemon/rpmostreed-daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ namespace rpmostreecxx
{
rust::Box<TokioEnterGuard> rpmostreed_daemon_tokio_enter (RpmostreedDaemon *self);
}

void reset_idle_exit_timer (GDBusConnection *connection, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name,
const gchar *signal_name, GVariant *parameters, gpointer user_data);