Allow counters with zero interval
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 5 Jan 2010 23:53:33 +0000 (15:53 -0800)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 5 Jan 2010 23:53:33 +0000 (15:53 -0800)
doc/manager-api.txt
src/counter.c

index 35477dc..1ba0480 100644 (file)
@@ -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)
index ae165e4..d897fb5 100644 (file)
@@ -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,