X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fsession.c;h=e847a6d58c7fcedc68e99525fa1a295daa5a09fb;hb=be4e0e2d3855ccbd3b683bfe6cc4c7f9d3254314;hp=22e50cfc5075a8400c9657fdf4718d951d62f9c1;hpb=f83af86907f072b8d58bc84acfb431682a9e3080;p=src%2Fapp-framework-binder.git diff --git a/src/session.c b/src/session.c index 22e50cfc..e847a6d5 100644 --- a/src/session.c +++ b/src/session.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 "IoT.bzh" + * Copyright (C) 2015, 2016 "IoT.bzh" * Author "Fulup Ar Foll" * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -48,6 +48,7 @@ struct afb_event_listener_list struct AFB_clientCtx { unsigned refcount; + unsigned loa; time_t expiration; // expiration time of the token time_t access; char uuid[37]; // long term authentication of remote client @@ -197,11 +198,10 @@ static void ctxStoreCleanUp (time_t now) // Loop on Sessions Table and remove anything that is older than timeout for (idx=0; idx < sessions.max; idx++) { - ctx = ctxClientAddRef(sessions.store[idx]); + ctx = sessions.store[idx]; if (ctx != NULL && ctxStoreTooOld(ctx, now)) { ctxClientClose (ctx); } - ctxClientUnref(ctx); } } @@ -291,6 +291,10 @@ void ctxClientClose (struct AFB_clientCtx *clientCtx) ctxUuidFreeCB (clientCtx); while(clientCtx->listeners != NULL) ctxClientEventListenerRemove(clientCtx, clientCtx->listeners->listener); + if (clientCtx->refcount == 0) { + ctxStoreDel (clientCtx); + free(clientCtx); + } } } @@ -431,6 +435,18 @@ const char *ctxClientGetToken (struct AFB_clientCtx *clientCtx) return clientCtx->token; } +unsigned ctxClientGetLOA (struct AFB_clientCtx *clientCtx) +{ + assert(clientCtx != NULL); + return clientCtx->loa; +} + +void ctxClientSetLOA (struct AFB_clientCtx *clientCtx, unsigned loa) +{ + assert(clientCtx != NULL); + clientCtx->loa = loa; +} + void *ctxClientValueGet(struct AFB_clientCtx *clientCtx, int index) { assert(clientCtx != NULL);