From 21974dca8364f3d267dd912e92521f6252dddf02 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Tue, 5 Apr 2016 16:52:35 +0200 Subject: [PATCH] renaming of session API MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Id9113a4e14da296d929fed0fd2f1dd7cfeba839b Signed-off-by: José Bollo --- src/afb-hreq.c | 2 +- src/afb-hsrv.c | 1 + src/session.c | 9 ++++++++- src/session.h | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/afb-hreq.c b/src/afb-hreq.c index 087a27ce..ece9b399 100644 --- a/src/afb-hreq.c +++ b/src/afb-hreq.c @@ -562,7 +562,7 @@ struct AFB_clientCtx *afb_hreq_context(struct afb_hreq *hreq) uuid = afb_hreq_get_argument(hreq, uuid_arg); if (uuid == NULL) uuid = afb_hreq_get_cookie(hreq, uuid_cookie); - hreq->context = ctxClientGet(uuid); + hreq->context = ctxClientGetForUuid(uuid); } return hreq->context; } diff --git a/src/afb-hsrv.c b/src/afb-hsrv.c index b5e6887b..2c294399 100644 --- a/src/afb-hsrv.c +++ b/src/afb-hsrv.c @@ -29,6 +29,7 @@ #include "local-def.h" #include "afb-method.h" #include "afb-hreq.h" +#include "afb-hsrv.h" #include "afb-websock.h" #include "afb-apis.h" #include "afb-req-itf.h" diff --git a/src/session.c b/src/session.c index e9cf298e..da2294bc 100644 --- a/src/session.c +++ b/src/session.c @@ -168,7 +168,7 @@ static void ctxStoreCleanUp (time_t now) } // This function will return exiting client context or newly created client context -struct AFB_clientCtx *ctxClientGet (const char *uuid) +struct AFB_clientCtx *ctxClientGetForUuid (const char *uuid) { uuid_t newuuid; struct AFB_clientCtx *clientCtx; @@ -215,6 +215,13 @@ struct AFB_clientCtx *ctxClientGet (const char *uuid) return NULL; } +struct AFB_clientCtx *ctxClientGet(struct AFB_clientCtx *clientCtx) +{ + if (clientCtx != NULL) + clientCtx->refcount++; + return clientCtx; +} + void ctxClientPut(struct AFB_clientCtx *clientCtx) { if (clientCtx != NULL) { diff --git a/src/session.h b/src/session.h index 28f25991..10af74fd 100644 --- a/src/session.h +++ b/src/session.h @@ -28,7 +28,8 @@ struct AFB_clientCtx extern void ctxStoreInit (int nbSession, int timeout, int apicount, const char *initok); -extern struct AFB_clientCtx *ctxClientGet (const char *uuid); +extern struct AFB_clientCtx *ctxClientGetForUuid (const char *uuid); +extern struct AFB_clientCtx *ctxClientGet(struct AFB_clientCtx *clientCtx); extern void ctxClientPut(struct AFB_clientCtx *clientCtx); extern void ctxClientClose (struct AFB_clientCtx *clientCtx); extern int ctxTokenCheck (struct AFB_clientCtx *clientCtx, const char *token); -- 2.16.6