dnsproxy: Only one copy of the relevant buffers will be made to a TCP request
[framework/connectivity/connman.git] / src / counter.c
index 6a0a994..1dd7d6d 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Connection Manager
  *
- *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2007-2012  Intel Corporation. All rights reserved.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License version 2 as
@@ -23,6 +23,8 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
+
 #include <gdbus.h>
 
 #include "connman.h"
@@ -45,9 +47,6 @@ static void remove_counter(gpointer user_data)
 
        DBG("owner %s path %s", counter->owner, counter->path);
 
-       if (counter->watch > 0)
-               g_dbus_remove_watch(connection, counter->watch);
-
        __connman_rtnl_update_interval_remove(counter->interval);
 
        __connman_service_counter_unregister(counter->path);
@@ -119,6 +118,9 @@ int __connman_counter_unregister(const char *owner, const char *path)
        if (g_strcmp0(owner, counter->owner) != 0)
                return -EACCES;
 
+       if (counter->watch > 0)
+               g_dbus_remove_watch(connection, counter->watch);
+
        g_hash_table_remove(owner_mapping, counter->owner);
        g_hash_table_remove(counter_table, counter->path);
 
@@ -150,6 +152,9 @@ static void release_counter(gpointer key, gpointer value, gpointer user_data)
 
        DBG("owner %s path %s", counter->owner, counter->path);
 
+       if (counter->watch > 0)
+               g_dbus_remove_watch(connection, counter->watch);
+
        message = dbus_message_new_method_call(counter->owner, counter->path,
                                        CONNMAN_COUNTER_INTERFACE, "Release");
        if (message == NULL)