[PATCH v3 09/10] service: Add session auto connect support

2014-02-04 Thread Daniel Wagner
From: Daniel Wagner 

Session are allowed to auto connect. This is done by checking the
reason code.

But before that we check if session are active. If yes we disable
the normal auto connect mode and only allow sessions to establish
new connections.
---
 src/service.c | 24 ++--
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/service.c b/src/service.c
index d852c38..b79dc05 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3738,7 +3738,8 @@ static bool auto_connect_service(GList *services,
bool autoconnecting = false;
GList *list;
 
-   DBG("preferred %d sessions %d", preferred, active_count);
+   DBG("preferred %d sessions %d reason %s", preferred, active_count,
+   reason2string(reason));
 
ignore[CONNMAN_SERVICE_TYPE_VPN] = true;
 
@@ -3777,14 +3778,25 @@ static bool auto_connect_service(GList *services,
CONNMAN_SERVICE_STATE_IDLE)
continue;
 
-   if (autoconnecting && !active_sessions[service->type]) {
-   DBG("service %p type %s has no users", service,
-   __connman_service_type2string(service->type));
-   continue;
+   if (active_count) {
+   DBG("session mode");
+
+   switch (reason) {
+   case CONNMAN_SERVICE_CONNECT_REASON_NONE:
+   case CONNMAN_SERVICE_CONNECT_REASON_USER:
+   case CONNMAN_SERVICE_CONNECT_REASON_AUTO:
+   /* disable normal auto connect for now */
+   continue;
+   case CONNMAN_SERVICE_CONNECT_REASON_SESSION:
+   if (!active_sessions[service->type])
+   /* no sessions is asking for this type 
*/
+   continue;
+   break;
+   }
}
 
DBG("service %p %s %s", service, service->name,
-   (preferred) ? "preferred" : "auto");
+   (preferred) ? "preferred" : reason2string(reason));
 
__connman_service_connect(service, reason);
 
-- 
1.8.5.3

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH v3 09/10] service: Add session auto connect support

2014-02-05 Thread Patrik Flykt

Hi,

On Tue, 2014-02-04 at 09:02 +0100, Daniel Wagner wrote:
> From: Daniel Wagner 
> 
> Session are allowed to auto connect. This is done by checking the
> reason code.
> 
> But before that we check if session are active. If yes we disable
> the normal auto connect mode and only allow sessions to establish
> new connections.
> ---
>  src/service.c | 24 ++--
>  1 file changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/src/service.c b/src/service.c
> index d852c38..b79dc05 100644
> --- a/src/service.c
> +++ b/src/service.c
> @@ -3738,7 +3738,8 @@ static bool auto_connect_service(GList *services,
>   bool autoconnecting = false;
>   GList *list;
>  
> - DBG("preferred %d sessions %d", preferred, active_count);
> + DBG("preferred %d sessions %d reason %s", preferred, active_count,
> + reason2string(reason));
>  
>   ignore[CONNMAN_SERVICE_TYPE_VPN] = true;
>  
> @@ -3777,14 +3778,25 @@ static bool auto_connect_service(GList *services,
>   CONNMAN_SERVICE_STATE_IDLE)
>   continue;
>  
> - if (autoconnecting && !active_sessions[service->type]) {
> - DBG("service %p type %s has no users", service,
> - __connman_service_type2string(service->type));
> - continue;
> + if (active_count) {
> + DBG("session mode");
> +
> + switch (reason) {
> + case CONNMAN_SERVICE_CONNECT_REASON_NONE:
> + case CONNMAN_SERVICE_CONNECT_REASON_USER:
> + case CONNMAN_SERVICE_CONNECT_REASON_AUTO:
> + /* disable normal auto connect for now */
> + continue;
> + case CONNMAN_SERVICE_CONNECT_REASON_SESSION:
> + if (!active_sessions[service->type])
> + /* no sessions is asking for this type 
> */
> + continue;
> + break;
> + }
>   }

No thanks. It should be possible to mix session triggered connects with
normal autoconnects. In patch 10 you have a good idea with the session
policy, let's explore that.

>  
>   DBG("service %p %s %s", service, service->name,
> - (preferred) ? "preferred" : "auto");
> + (preferred) ? "preferred" : reason2string(reason));
>  
>   __connman_service_connect(service, reason);
>  

Cheers,

Patrik


___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH v3 09/10] service: Add session auto connect support

2014-02-07 Thread Daniel Wagner
Hi Patrik,

On 02/05/2014 12:43 PM, Patrik Flykt wrote:
> On Tue, 2014-02-04 at 09:02 +0100, Daniel Wagner wrote:
>> From: Daniel Wagner 
>>
>> Session are allowed to auto connect. This is done by checking the
>> reason code.
>>
>> But before that we check if session are active. If yes we disable
>> the normal auto connect mode and only allow sessions to establish
>> new connections.
>> ---
>>  src/service.c | 24 ++--
>>  1 file changed, 18 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/service.c b/src/service.c
>> index d852c38..b79dc05 100644
>> --- a/src/service.c
>> +++ b/src/service.c
>> @@ -3738,7 +3738,8 @@ static bool auto_connect_service(GList *services,
>>  bool autoconnecting = false;
>>  GList *list;
>>  
>> -DBG("preferred %d sessions %d", preferred, active_count);
>> +DBG("preferred %d sessions %d reason %s", preferred, active_count,
>> +reason2string(reason));
>>  
>>  ignore[CONNMAN_SERVICE_TYPE_VPN] = true;
>>  
>> @@ -3777,14 +3778,25 @@ static bool auto_connect_service(GList *services,
>>  CONNMAN_SERVICE_STATE_IDLE)
>>  continue;
>>  
>> -if (autoconnecting && !active_sessions[service->type]) {
>> -DBG("service %p type %s has no users", service,
>> -__connman_service_type2string(service->type));
>> -continue;
>> +if (active_count) {
>> +DBG("session mode");
>> +
>> +switch (reason) {
>> +case CONNMAN_SERVICE_CONNECT_REASON_NONE:
>> +case CONNMAN_SERVICE_CONNECT_REASON_USER:
>> +case CONNMAN_SERVICE_CONNECT_REASON_AUTO:
>> +/* disable normal auto connect for now */
>> +continue;
>> +case CONNMAN_SERVICE_CONNECT_REASON_SESSION:
>> +if (!active_sessions[service->type])
>> +/* no sessions is asking for this type 
>> */
>> +continue;
>> +break;
>> +}
>>  }
> 
> No thanks. It should be possible to mix session triggered connects with
> normal autoconnects.

We have two different objectives here. I'd like to have a system idle
with free-ride session only and you want to stay connected all the time.

> In patch 10 you have a good idea with the session
> policy, let's explore that.

Sure we can go into direction of having several auto connect
implementation instead of a generic one. Maybe we need to expose a bit
of internal information later one but let's see how this works.

cheers,
daniel
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman