agent: Cancel agent requests
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 3 Sep 2012 11:17:14 +0000 (14:17 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 4 Sep 2012 09:09:16 +0000 (12:09 +0300)
Clean up any queued Agent API messages when the agent disappears or
the service is disconnected. Send cancel to the agent on D-Bus
timeout.

src/agent.c
src/service.c

index 132aa85..aff41df 100644 (file)
@@ -59,6 +59,8 @@ static void agent_free(void)
 
        g_free(agent_path);
        agent_path = NULL;
+
+       __connman_agent_cancel(NULL);
 }
 
 static void agent_disconnect(DBusConnection *conn, void *data)
@@ -186,6 +188,13 @@ static void agent_receive_message(DBusPendingCall *call, void *user_data)
        dbus_pending_call_unref(call);
        queue_data->call = NULL;
 
+       if (dbus_message_is_error(reply, "org.freedesktop.DBus.Error.Timeout")
+                       == TRUE || dbus_message_is_error(reply,
+                                       "org.freedesktop.DBus.Error.TimedOut")
+                       == TRUE) {
+               agent_send_cancel();
+       }
+
        queue_data->callback(reply, queue_data->user_data);
        dbus_message_unref(reply);
 
index 595381d..3e4c5bf 100644 (file)
@@ -5686,6 +5686,8 @@ int __connman_service_disconnect(struct connman_service *service)
 
        DBG("service %p", service);
 
+       __connman_agent_cancel(service);
+
        if (service->network != NULL) {
                err = __connman_network_disconnect(service->network);
        } else if (service->type == CONNMAN_SERVICE_TYPE_VPN &&