From ded3e33a21945a95394dd092bfd34f145b8c6138 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 5 Jan 2010 15:53:33 -0800 Subject: [PATCH] Allow counters with zero interval --- doc/manager-api.txt | 5 +++++ src/counter.c | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/manager-api.txt b/doc/manager-api.txt index 35477dc..1ba0480 100644 --- a/doc/manager-api.txt +++ b/doc/manager-api.txt @@ -109,6 +109,11 @@ Methods dict GetProperties() Register a new counter for user notifications. + If the interval is zero then no timer for updates + will be started. Only kernel events can then + trigger updates. Otherwise the kernel will be + polled every n seconds for an update. + Possible Errors: [service].Error.InvalidArguments void UnregisterCounter(object path) diff --git a/src/counter.c b/src/counter.c index ae165e4..d897fb5 100644 --- a/src/counter.c +++ b/src/counter.c @@ -99,9 +99,6 @@ int __connman_counter_register(const char *owner, const char *path, DBG("owner %s path %s interval %u", owner, path, interval); - if (interval < 1) - return -EINVAL; - counter = g_hash_table_lookup(counter_table, path); if (counter != NULL) return -EEXIST; @@ -116,7 +113,8 @@ int __connman_counter_register(const char *owner, const char *path, g_hash_table_replace(counter_table, counter->path, counter); g_hash_table_replace(owner_mapping, counter->owner, counter); - counter->timeout = g_timeout_add_seconds(interval, + if (interval > 0) + counter->timeout = g_timeout_add_seconds(interval, counter_timeout, counter); counter->watch = g_dbus_add_disconnect_watch(connection, owner, -- 2.7.4