diff options
author | Alexander Larsson <alexl@redhat.com> | 2019-09-27 15:25:01 +0200 |
---|---|---|
committer | Alexander Larsson <alexander.larsson@gmail.com> | 2019-10-02 14:57:11 +0200 |
commit | 82328bee85165aba4deb6ef118e74733aec5f1a5 (patch) | |
tree | 9beed54ead1fa2a1b121e42ffd2519f8e99b7ce3 /portal | |
parent | a4b2068bbc30a9e93ba047915a489360868dfa20 (diff) | |
download | flatpak-82328bee85165aba4deb6ef118e74733aec5f1a5.tar.gz |
portal: Add option for poll frequency
We want to use these to get a quick turnaround in the tests.
Diffstat (limited to 'portal')
-rw-r--r-- | portal/flatpak-portal.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/portal/flatpak-portal.c b/portal/flatpak-portal.c index c921a970..71701dc8 100644 --- a/portal/flatpak-portal.c +++ b/portal/flatpak-portal.c @@ -58,6 +58,7 @@ static guint name_owner_id = 0; static GMainLoop *main_loop; static PortalFlatpak *portal; static gboolean opt_verbose; +static int opt_poll_timeout; G_LOCK_DEFINE (update_monitors); /* This protects the three variables below */ static GHashTable *update_monitors; @@ -65,7 +66,7 @@ static guint update_monitors_timeout = 0; static gboolean update_monitors_timeout_running_thread = FALSE; /* Poll all update monitors twice an hour */ -#define UPDATE_POLL_TIMEOUT_SEC (30 * 60) +#define DEFAULT_UPDATE_POLL_TIMEOUT_SEC (30 * 60) #define PERMISSION_TABLE "flatpak" #define PERMISSION_ID "updates" @@ -798,7 +799,7 @@ register_update_monitor (PortalFlatpakUpdateMonitor *monitor, /* Trigger update timeout if needed */ if (update_monitors_timeout == 0 && !update_monitors_timeout_running_thread) - update_monitors_timeout = g_timeout_add_seconds (UPDATE_POLL_TIMEOUT_SEC, check_all_for_updates_cb, NULL); + update_monitors_timeout = g_timeout_add_seconds (opt_poll_timeout, check_all_for_updates_cb, NULL); G_UNLOCK (update_monitors); } @@ -1168,7 +1169,7 @@ check_all_for_updates_in_thread_func (GTask *task, update_monitors_timeout_running_thread = FALSE; if (g_hash_table_size (update_monitors) > 0) - update_monitors_timeout = g_timeout_add_seconds (UPDATE_POLL_TIMEOUT_SEC, check_all_for_updates_cb, NULL); + update_monitors_timeout = g_timeout_add_seconds (opt_poll_timeout, check_all_for_updates_cb, NULL); G_UNLOCK (update_monitors); } @@ -2088,6 +2089,7 @@ main (int argc, { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Enable debug output.", NULL }, { "version", 0, 0, G_OPTION_ARG_NONE, &show_version, "Show program version.", NULL}, { "no-idle-exit", 0, 0, G_OPTION_ARG_NONE, &no_idle_exit, "Don't exit when idle.", NULL }, + { "poll-timeout", 0, 0, G_OPTION_ARG_INT, &opt_poll_timeout, "Delay in seconds between polls for updates.", NULL }, { NULL } }; @@ -2124,6 +2126,9 @@ main (int argc, return 1; } + if (opt_poll_timeout == 0) + opt_poll_timeout = DEFAULT_UPDATE_POLL_TIMEOUT_SEC; + if (show_version) { g_print (PACKAGE_STRING "\n"); |