X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-context.c;h=5fe327648374a8ed37a769b02d42fb69c1be9b57;hb=15c3a8b1ef47127d30d8b5f26f9d7622a0b72656;hp=48787f79e371c8d223a8173ae69685636e5cbf29;hpb=457c879ff89bc7f1a8864304974999dba54af9ae;p=src%2Fapp-framework-binder.git diff --git a/src/afb-context.c b/src/afb-context.c index 48787f79..5fe32764 100644 --- a/src/afb-context.c +++ b/src/afb-context.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2015, 2016 "IoT.bzh" * Author "Fulup Ar Foll" + * Author José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +59,7 @@ int afb_context_connect(struct afb_context *context, const char *uuid, const cha init_context(context, session, token); if (created) { context->created = 1; - context->refreshing = 1; + /* context->refreshing = 1; */ } return 0; } @@ -74,7 +75,7 @@ void afb_context_disconnect(struct afb_context *context) ctxClientSetLOA (context->session, context->loa_out); context->loa_changed = 1; } - if (!context->closed) { + if (context->closing && !context->closed) { ctxClientClose(context->session); context->closed = 1; } @@ -138,16 +139,19 @@ int afb_context_check_loa(struct afb_context *context, unsigned loa) return context->loa_in >= loa; } -void afb_context_change_loa(struct afb_context *context, unsigned loa) +int afb_context_change_loa(struct afb_context *context, unsigned loa) { - assert(context->validated); + if (!context->validated || loa > 7) + return 0; - if (loa == context->loa_in) + if (loa == context->loa_in && !context->loa_changed) context->loa_changing = 0; else { - context->loa_changing = 1; context->loa_out = loa & 7; + context->loa_changing = 1; + context->loa_changed = 0; } + return 1; }