Call __connman_notifier_connect() only when state is READY
authorMartin Xu <martin.xu@intel.com>
Wed, 5 May 2010 15:26:59 +0000 (23:26 +0800)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 6 May 2010 05:39:56 +0000 (07:39 +0200)
If we call it at READY or ONLINE state, The function will be called
twice and connected times is set as two. And StateChanged signal "offline"
will never be emitted.

Commit 59a8daa3 ("ONLINE and LOGIN are also "connected" states.") added
a check for also state CONNMAN_SERVICE_STATE_LOGIN in
__connman_service_indicate_state(). But this meant that
__connman_notifier_connect() was called twice for each service, first in
READY state and then in LOGIN state. This broke refcounting in notifier.c
and caused a bug that Manager interface would always clame to be in
online state after a first successful connection even if all services were
disconnected.

src/service.c

index ff623e6..31d4004 100644 (file)
@@ -1620,8 +1620,7 @@ int __connman_service_indicate_state(struct connman_service *service,
                        __connman_service_auto_connect();
        }
 
-       if (state == CONNMAN_SERVICE_STATE_READY ||
-                       state == CONNMAN_SERVICE_STATE_ONLINE) {
+       if (state == CONNMAN_SERVICE_STATE_READY) {
                set_reconnect_state(service, TRUE);
 
                __connman_service_set_favorite(service, TRUE);