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

Jukka Rissanen jukka.rissanen at linux.intel.com
Tue Sep 10 05:41:26 PDT 2013


On 10.09.2013 15:25, Patrik Flykt wrote:
>
> 	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?

Yes it is.

After some offline discussion, I will refactor the set_default_agent() code.


Cheers,
Jukka




More information about the connman mailing list