Hi,

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;

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

Cheers,

        Patrik

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

Reply via email to