renaming of session API
authorJosé Bollo <jose.bollo@iot.bzh>
Tue, 5 Apr 2016 14:52:35 +0000 (16:52 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Tue, 5 Apr 2016 14:52:35 +0000 (16:52 +0200)
Change-Id: Id9113a4e14da296d929fed0fd2f1dd7cfeba839b
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/afb-hreq.c
src/afb-hsrv.c
src/session.c
src/session.h

index 087a27c..ece9b39 100644 (file)
@@ -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;
 }
index b5e6887..2c29439 100644 (file)
@@ -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"
index e9cf298..da2294b 100644 (file)
@@ -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) {
index 28f2599..10af74f 100644 (file)
@@ -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);