[PATCH v2 6/8] agent: Add multi agent support

Patrik Flykt patrik.flykt at linux.intel.com
Mon Sep 9 05:29:20 PDT 2013


	Hi,

On Fri, 2013-09-06 at 14:12 +0300, Jukka Rissanen wrote:

> +static void agent_release(struct connman_agent *agent, const char
> *interface)
> +{
> +       DBusMessage *message;
> +
> +       DBG("release agent %s %s", agent->owner, agent->path);
> +
> +       message = dbus_message_new_method_call(agent->owner,
> agent->path,
> +                                               interface, "Release");
> +       if (message == NULL) {
> +               connman_error("Couldn't allocate D-Bus message");
> +               return;
> +       }
> +
> +       dbus_message_set_no_reply(message, TRUE);
> +       g_dbus_send_message(connection, message);
> +}
> +
...
> -static void release_all_agents(void)
> +static void agent_destroy(gpointer data)
>  {
> -       connman_agent_driver_unregister(get_driver());
> +       struct connman_agent *agent = data;
> +
> +       DBG("agent %s req %p", agent->owner, agent->request);
> +
> +       if (agent->watch > 0) {
> +               g_dbus_remove_watch(connection, agent->watch);
> +               agent->watch = 0;
> +       }
> +
> +       agent_release(agent, get_driver()->interface);
> +
> +       agent_unref(agent);
> +}
> +
> +int connman_agent_unregister(const char *sender, const char *path)
> +{
> +       DBG("sender %s path %s", sender, path);
> +
> +       if (!g_hash_table_remove(agent_hash, sender))
> +               return -ESRCH;
> +
> +       return 0;
>  }
>  
>  int __connman_agent_init(void)
> @@ -466,7 +613,12 @@ int __connman_agent_init(void)
>  
>         connection = connman_dbus_get_connection();
>         if (!connection)
> -               return -1;
> +               return -EINVAL;
> +
> +       agent_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
> +                                               NULL, agent_destroy);
> +       if (!agent_hash)
> +               return -ENOMEM;

It seems the code will always send a 'Release' message when an agent is
removed from the agent_hash. That is unnecessary if the Agent is
properly unregistering itself via D-Bus, in these cases a 'Release'
message should not be sent.

Cheers,

	Patrik




More information about the connman mailing list