mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-04-18 09:40:38 +02:00
daemon: Better timeout source naming
Matching the work done in glib, gtk+, etc. This also differentiates the unknown and normal timeouts in the Linux power supply driver.
This commit is contained in:
parent
4d0af3b31b
commit
6e8e659ca2
13 changed files with 41 additions and 18 deletions
|
|
@ -100,7 +100,7 @@ up_backend_add_cb (UpBackend *backend)
|
|||
|
||||
/* setup poll */
|
||||
timer_id = g_timeout_add_seconds (2, (GSourceFunc) up_backend_changed_time_cb, backend);
|
||||
g_source_set_name_by_id (timer_id, "[UpBackend] changed");
|
||||
g_source_set_name_by_id (timer_id, "[upower] up_backend_changed_time_cb (dummy)");
|
||||
out:
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
|
|||
g_timeout_add_seconds (UP_BACKEND_REFRESH_TIMEOUT,
|
||||
(GSourceFunc) up_backend_refresh_devices,
|
||||
backend);
|
||||
g_source_set_name_by_id (backend->priv->poll_timer_id, "[FreeBSD:UpBackend] poll");
|
||||
g_source_set_name_by_id (backend->priv->poll_timer_id, "[upower] up_backend_refresh_devices (freebsd)");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ up_device_csr_coldplug (UpDevice *device)
|
|||
csr->priv->poll_timer_id = g_timeout_add_seconds (UP_DEVICE_CSR_REFRESH_TIMEOUT,
|
||||
(GSourceFunc) up_device_csr_poll_cb, csr);
|
||||
|
||||
g_source_set_name_by_id (csr->priv->poll_timer_id, "[UpDeviceCsr] poll");
|
||||
g_source_set_name_by_id (csr->priv->poll_timer_id, "[upower] up_device_csr_poll_cb (linux)");
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ up_device_hid_init (UpDeviceHid *hid)
|
|||
hid->priv->fd = -1;
|
||||
hid->priv->poll_timer_id = g_timeout_add_seconds (UP_DEVICE_HID_REFRESH_TIMEOUT,
|
||||
(GSourceFunc) up_device_hid_poll, hid);
|
||||
g_source_set_name_by_id (hid->priv->poll_timer_id, "[UpDeviceHid] poll");
|
||||
g_source_set_name_by_id (hid->priv->poll_timer_id, "[upower] up_device_hid_poll (linux)");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ up_device_idevice_coldplug (UpDevice *device)
|
|||
idevice->priv->poll_timer_id = g_timeout_add_seconds (poll_seconds,
|
||||
(GSourceFunc) up_device_idevice_poll_cb, idevice);
|
||||
|
||||
g_source_set_name_by_id (idevice->priv->poll_timer_id, "[UpDeviceIdevice] poll");
|
||||
g_source_set_name_by_id (idevice->priv->poll_timer_id, "[upower] up_device_idevice_poll_cb (linux)");
|
||||
return TRUE;
|
||||
|
||||
out:
|
||||
|
|
|
|||
|
|
@ -897,11 +897,17 @@ up_device_supply_refresh_device (UpDeviceSupply *supply,
|
|||
* up_device_supply_poll_battery:
|
||||
**/
|
||||
static gboolean
|
||||
up_device_supply_poll_battery (UpDeviceSupply *supply)
|
||||
up_device_supply_poll_battery (UpDeviceSupply *supply,
|
||||
guint timeout)
|
||||
{
|
||||
UpDevice *device = UP_DEVICE (supply);
|
||||
|
||||
g_debug ("No updates on supply %s for %i seconds; forcing update", up_device_get_object_path (device), UP_DEVICE_SUPPLY_REFRESH_TIMEOUT);
|
||||
if (timeout == UP_DEVICE_SUPPLY_UNKNOWN_TIMEOUT)
|
||||
g_debug ("Unknown state on supply %s; forcing update after %i seconds",
|
||||
up_device_get_object_path (device), timeout);
|
||||
else
|
||||
g_debug ("No updates on supply %s for %i seconds; forcing update",
|
||||
up_device_get_object_path (device), timeout);
|
||||
supply->priv->poll_timer_id = 0;
|
||||
up_device_supply_refresh (device);
|
||||
|
||||
|
|
@ -909,6 +915,18 @@ up_device_supply_poll_battery (UpDeviceSupply *supply)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
up_device_supply_poll_battery_normal (UpDeviceSupply *supply)
|
||||
{
|
||||
return up_device_supply_poll_battery (supply, UP_DEVICE_SUPPLY_REFRESH_TIMEOUT);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
up_device_supply_poll_unknown_battery (UpDeviceSupply *supply)
|
||||
{
|
||||
return up_device_supply_poll_battery (supply, UP_DEVICE_SUPPLY_UNKNOWN_TIMEOUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* up_device_supply_coldplug:
|
||||
*
|
||||
|
|
@ -1061,8 +1079,8 @@ up_device_supply_setup_poll (UpDevice *device,
|
|||
supply->priv->unknown_retries < UP_DEVICE_SUPPLY_UNKNOWN_RETRIES) {
|
||||
supply->priv->poll_timer_id =
|
||||
g_timeout_add_seconds (UP_DEVICE_SUPPLY_UNKNOWN_TIMEOUT,
|
||||
(GSourceFunc) up_device_supply_poll_battery, supply);
|
||||
g_source_set_name_by_id (supply->priv->poll_timer_id, "[UpDeviceSupply] unknown poll");
|
||||
(GSourceFunc) up_device_supply_poll_unknown_battery, supply);
|
||||
g_source_set_name_by_id (supply->priv->poll_timer_id, "[upower] up_device_supply_poll_unknown_battery (linux)");
|
||||
|
||||
/* increase count, we don't want to poll at 0.5Hz forever */
|
||||
supply->priv->unknown_retries++;
|
||||
|
|
@ -1072,8 +1090,8 @@ up_device_supply_setup_poll (UpDevice *device,
|
|||
/* any other state just fall back */
|
||||
supply->priv->poll_timer_id =
|
||||
g_timeout_add_seconds (UP_DEVICE_SUPPLY_REFRESH_TIMEOUT,
|
||||
(GSourceFunc) up_device_supply_poll_battery, supply);
|
||||
g_source_set_name_by_id (supply->priv->poll_timer_id, "[UpDeviceSupply] normal poll");
|
||||
(GSourceFunc) up_device_supply_poll_battery_normal, supply);
|
||||
g_source_set_name_by_id (supply->priv->poll_timer_id, "[upower] up_device_supply_poll_battery_normal (linux)");
|
||||
out:
|
||||
return (supply->priv->poll_timer_id != 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -292,6 +292,7 @@ up_device_unifying_coldplug (UpDevice *device)
|
|||
unifying->priv->poll_timer_id = g_timeout_add_seconds (UP_DEVICE_UNIFYING_REFRESH_TIMEOUT,
|
||||
(GSourceFunc) up_device_unifying_refresh,
|
||||
device);
|
||||
g_source_set_name_by_id (unifying->priv->poll_timer_id, "[upower] up_device_unifying_refresh (linux)");
|
||||
ret = TRUE;
|
||||
out:
|
||||
g_list_foreach (hidraw_list, (GFunc) g_object_unref, NULL);
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ up_device_wup_init (UpDeviceWup *wup)
|
|||
wup->priv->fd = -1;
|
||||
wup->priv->poll_timer_id = g_timeout_add_seconds (UP_DEVICE_WUP_REFRESH_TIMEOUT,
|
||||
(GSourceFunc) up_device_wup_poll_cb, wup);
|
||||
g_source_set_name_by_id (wup->priv->poll_timer_id, "[UpDeviceWup] poll");
|
||||
g_source_set_name_by_id (wup->priv->poll_timer_id, "[upower] up_device_wup_poll_cb (linux)");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ up_dock_set_should_poll (UpDock *dock, gboolean should_poll)
|
|||
dock->priv->poll_id = g_timeout_add_seconds (UP_DOCK_POLL_TIMEOUT,
|
||||
(GSourceFunc) up_dock_poll_cb,
|
||||
dock);
|
||||
g_source_set_name_by_id (dock->priv->poll_id, "[upower] up_dock_poll_cb (linux)");
|
||||
} else if (dock->priv->poll_id > 0) {
|
||||
g_source_remove (dock->priv->poll_id);
|
||||
dock->priv->poll_id = 0;
|
||||
|
|
|
|||
|
|
@ -770,6 +770,7 @@ up_daemon_set_warning_level (UpDaemon *daemon, UpDeviceLevel warning_level)
|
|||
daemon->priv->action_timeout_id = g_timeout_add_seconds (UP_DAEMON_ACTION_DELAY,
|
||||
(GSourceFunc) take_action_timeout_cb,
|
||||
daemon);
|
||||
g_source_set_name_by_id (daemon->priv->action_timeout_id, "[upower] take_action_timeout_cb");
|
||||
} else {
|
||||
g_debug ("Not taking action, timeout id already set");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -652,7 +652,7 @@ up_history_schedule_save (UpHistory *history)
|
|||
g_debug ("saving in %i seconds", UP_HISTORY_SAVE_INTERVAL);
|
||||
history->priv->save_id = g_timeout_add_seconds (UP_HISTORY_SAVE_INTERVAL,
|
||||
(GSourceFunc) up_history_schedule_save_cb, history);
|
||||
g_source_set_name_by_id (history->priv->save_id, "[UpHistory] save");
|
||||
g_source_set_name_by_id (history->priv->save_id, "[upower] up_history_schedule_save_cb");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -267,12 +267,14 @@ main (gint argc, gchar **argv)
|
|||
/* only timeout and close the mainloop if we have specified it on the command line */
|
||||
if (timed_exit) {
|
||||
timer_id = g_timeout_add_seconds (30, (GSourceFunc) up_main_timed_exit_cb, loop);
|
||||
g_source_set_name_by_id (timer_id, "[UpMain] idle");
|
||||
g_source_set_name_by_id (timer_id, "[upower] up_main_timed_exit_cb");
|
||||
}
|
||||
|
||||
/* immediatly exit */
|
||||
if (immediate_exit)
|
||||
if (immediate_exit) {
|
||||
g_timeout_add (50, (GSourceFunc) up_main_timed_exit_cb, loop);
|
||||
g_source_set_name_by_id (timer_id, "[upower] up_main_timed_exit_cb");
|
||||
}
|
||||
|
||||
/* wait for input or timeout */
|
||||
g_main_loop_run (loop);
|
||||
|
|
|
|||
|
|
@ -634,7 +634,7 @@ up_wakeups_timerstats_enable (UpWakeups *wakeups)
|
|||
wakeups->priv->disable_id =
|
||||
g_timeout_add_seconds (UP_WAKEUPS_DISABLE_INTERVAL,
|
||||
(GSourceFunc) up_wakeups_disable_cb, wakeups);
|
||||
g_source_set_name_by_id (wakeups->priv->disable_id, "[UpWakeups] disable");
|
||||
g_source_set_name_by_id (wakeups->priv->disable_id, "[upower] up_wakeups_disable_cb");
|
||||
|
||||
/* already same state */
|
||||
if (wakeups->priv->polling_enabled)
|
||||
|
|
@ -646,12 +646,12 @@ up_wakeups_timerstats_enable (UpWakeups *wakeups)
|
|||
wakeups->priv->poll_kernel_id =
|
||||
g_timeout_add_seconds (UP_WAKEUPS_POLL_INTERVAL_KERNEL,
|
||||
(GSourceFunc) up_wakeups_poll_kernel_cb, wakeups);
|
||||
g_source_set_name_by_id (wakeups->priv->poll_kernel_id, "[UpWakeups] kernel");
|
||||
g_source_set_name_by_id (wakeups->priv->poll_kernel_id, "[upower] up_wakeups_poll_kernel_cb");
|
||||
|
||||
wakeups->priv->poll_userspace_id =
|
||||
g_timeout_add_seconds (UP_WAKEUPS_POLL_INTERVAL_USERSPACE,
|
||||
(GSourceFunc) up_wakeups_poll_userspace_cb, wakeups);
|
||||
g_source_set_name_by_id (wakeups->priv->poll_userspace_id, "[UpWakeups] userspace");
|
||||
g_source_set_name_by_id (wakeups->priv->poll_userspace_id, "[upower] up_wakeups_poll_userspace_cb");
|
||||
|
||||
file = fopen (UP_WAKEUPS_SOURCE_USERSPACE, "w");
|
||||
if (file == NULL)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue