Hi Patrik,

On 01/09/2014 02:28 PM, Patrik Flykt wrote:
> On Fri, 2013-12-13 at 09:34 +0100, Daniel Wagner wrote:
>> From: Daniel Wagner <[email protected]>
>>
>> When SessionAutoConnectMode is enabled we should also make sure
>> we disconnect unused Services. Unused means there is no
>> Session is using a Service (__connman_session_in_use()) and
>> asking for a connection (__connman_session_wants_connection())
>>
>> Note if the user did a Service.Connect() (service->userconnect)
>> we won't disconnect the Service.
>>
>> The algorithm could potentially be merged into auto_connect_service()
>> but this function is already complex enough let's have a
>> auto_disconnect_service() which runs after auto_connect_service(). The
>> upside is that we don't change the current play with auto connect
>> as it seems to work correctly.
>> ---
>>  src/connman.h |  2 ++
>>  src/service.c | 38 ++++++++++++++++++++++++++++++++++++++
>>  src/session.c | 40 ++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 80 insertions(+)
>>
>> diff --git a/src/connman.h b/src/connman.h
>> index dd9fa97..7b107b5 100644
>> --- a/src/connman.h
>> +++ b/src/connman.h
>> @@ -824,6 +824,8 @@ void __connman_session_set_mode(bool enable);
>>  int __connman_session_create(DBusMessage *msg);
>>  int __connman_session_destroy(DBusMessage *msg);
>>  
>> +bool __connman_session_wants_connection(struct connman_service *service);
>> +bool __connman_session_in_use(struct connman_service *service);
>>  bool __connman_session_active_sessions(struct connman_service *service);
>>  bool __connman_session_running(void);
>>  
>> diff --git a/src/service.c b/src/service.c
>> index 446b145..6e0b27f 100644
>> --- a/src/service.c
>> +++ b/src/service.c
>> @@ -3577,6 +3577,41 @@ static bool auto_connect_service(GList *services, 
>> bool preferred)
>>      return autoconnecting;
>>  }
>>  
>> +static void auto_disconnect_service(void)
> 
> If we had a "cause" in the service struct, i.e.
> 
> enum service_connect_reason = {
>       CONNMAN_SERVICE_CONNECT_AUTO    = 1,
>       CONNMAN_SERVICE_CONNECT_USER    = 2,
>       CONNMAN_SERVICE_CONNECT_SESSION = 3,
> };
> 
> that would replace service->userconnect, we could disconnect the service
> immediately when the last session stops using it (actually, the bearer)
> if service->connect_reason == CONNMAN_SERVICE_CONNECT_SESSION;

I don't see how this would help currently because AUTO and SESSION is
essentially the same. auto_connect_service() does not care who has
asked for a connection.

The only why to influence is it via is_ignore() and active_count
respectively __connman_session_active_sessions() in this patch
series.

I would suggest we stick to the current version of
auto_connect_service() and modify it in the next step.

> With that there would not be any reason to add this kind of disconnect
> functionality run once in a while.

We need to run the auto connect algorithm any time the configuration
of a session changes. It is far from random or 'once in a while'.

cheers,
daniel
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to