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

Patrik Flykt patrik.flykt at linux.intel.com
Tue Sep 10 05:25:24 PDT 2013


	Hi,

A longer commit message with an explanation of what is going on would be
nice.

On Tue, 2013-09-10 at 14:38 +0300, Jukka Rissanen wrote:
> +static void set_default_agent(struct connman_agent *agent)
>  {
> -       GList *item, *next;
> -       struct connman_agent_request *queued_req;
> -       int err;
> +       if (default_agent == agent)
> +               return;
>  
> -       DBG("context %p", user_context);
> +       if (!agent) {
> +               GHashTableIter iter;
> +               gpointer key, value;
>  
> -       item = agent_queue;
> +               g_hash_table_iter_init(&iter, agent_hash);
> +               while (g_hash_table_iter_next(&iter, &key, &value)) {
> +                       agent = value;
>  
> -       while (item) {
> -               next = g_list_next(item);
> -               queued_req = item->data;
> +                       if (default_agent != agent)
> +                               break;
>  
> -               if (queued_req->user_context == user_context ||
> -                                                       !user_context)
> {
> -                       agent_data_free(queued_req);
> -                       agent_queue = g_list_delete_link(agent_queue,
> item);
> +                       agent = NULL;
>                 }
> -
> -               item = next;
>         }
>  
> -       if (!agent_request)
> -               return;
> +       if (agent)
> +               DBG("default agent set to %s %s", agent->owner,
> agent->path);
> +       else
> +               DBG("default agent cleared");
> +
> +       default_agent = agent;
> +} 

If only one agent exists and the default_agent is set to that one agent,
calling set_default_agent(NULL) will unset the agent. If two agents
exist with one of them set as default_agent, calling
set_default_agent(NULL) will select the other agent. Is this the
intended behavior? 

Cheers,

	Patrik



More information about the connman mailing list