X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fsession.c;h=66876cd99332a97e34d2f37d9fd3f16a0c6b06cb;hb=2a3fbda636c93c9f22a064e5c5f537c2232d626d;hp=6aa018b16bb7829467c62c09b016a0fbb576456a;hpb=96b44f68e34f41c145b54ad2f7c4051c7d07ecb0;p=src%2Fapp-framework-binder.git diff --git a/src/session.c b/src/session.c index 6aa018b1..66876cd9 100644 --- a/src/session.c +++ b/src/session.c @@ -338,10 +338,9 @@ STATIC void ctxUuidFreeCB (AFB_clientCtx *client) { // Create a new store in RAM, not that is too small it will be automatically extended PUBLIC void ctxStoreInit (int nbSession) { - int res; // let's create as store as hashtable does not have any - sessions.store = calloc (nbSession+1, sizeof(AFB_clientCtx)); + sessions.store = calloc (1 + (unsigned)nbSession, sizeof(AFB_clientCtx)); sessions.max=nbSession; } @@ -421,7 +420,7 @@ STATIC int ctxStoreToOld (AFB_clientCtx *ctx, int timeout) { } // Loop on every entry and remove old context sessions.hash -PUBLIC int ctxStoreGarbage (const int timeout) { +PUBLIC void ctxStoreGarbage (const int timeout) { AFB_clientCtx *ctx; long idx; @@ -439,7 +438,6 @@ PUBLIC AFB_clientCtx *ctxClientGet (AFB_request *request, int idx) { AFB_clientCtx *clientCtx=NULL; const char *uuid; uuid_t newuuid; - int ret; if (request->config->token == NULL) return NULL; @@ -449,13 +447,14 @@ PUBLIC AFB_clientCtx *ctxClientGet (AFB_request *request, int idx) { // if UUID in query we're restfull with no cookies otherwise check for cookie if (uuid != NULL) request->restfull = TRUE; else { + char cookie[64]; request->restfull = FALSE; - uuid = MHD_lookup_connection_value (request->connection, MHD_COOKIE_KIND, COOKIE_NAME); + snprintf(cookie, sizeof cookie, "%s-%d", COOKIE_NAME, request->config->httpdPort); + uuid = MHD_lookup_connection_value (request->connection, MHD_COOKIE_KIND, cookie); }; // Warning when no cookie defined MHD_lookup_connection_value may return something !!! if ((uuid != NULL) && (strnlen (uuid, 10) >= 10)) { - int search; // search if client context exist and it not timeout let's use it clientCtx = ctxStoreSearch (uuid); @@ -476,7 +475,7 @@ PUBLIC AFB_clientCtx *ctxClientGet (AFB_request *request, int idx) { // we have no session let's create one otherwise let's clean any exiting values if (clientCtx == NULL) { clientCtx = calloc(1, sizeof(AFB_clientCtx)); // init NULL clientContext - clientCtx->contexts = calloc (1, request->config->pluginCount * (sizeof (void*))); + clientCtx->contexts = calloc (1, (unsigned)request->config->pluginCount * (sizeof (void*))); clientCtx->plugins = request->plugins; } @@ -522,9 +521,9 @@ PUBLIC AFB_error ctxTokenCheck (AFB_clientCtx *clientCtx, AFB_request *request) // Free Client Session Context PUBLIC AFB_error ctxTokenReset (AFB_clientCtx *clientCtx, AFB_request *request) { - int ret; if (clientCtx == NULL) return AFB_EMPTY; + //if (verbose) fprintf (stderr, "ctxClientReset New uuid=[%s] token=[%s] timestamp=%d\n", clientCtx->uuid, clientCtx->token, clientCtx->timeStamp); // Search for an existing client with the same UUID clientCtx = ctxStoreSearch (clientCtx->uuid); @@ -538,8 +537,6 @@ PUBLIC AFB_error ctxTokenReset (AFB_clientCtx *clientCtx, AFB_request *request) // generate a new token PUBLIC AFB_error ctxTokenCreate (AFB_clientCtx *clientCtx, AFB_request *request) { - int oldTnkValid; - const char *ornew; uuid_t newuuid; const char *token; @@ -570,8 +567,6 @@ PUBLIC AFB_error ctxTokenCreate (AFB_clientCtx *clientCtx, AFB_request *request) // generate a new token and update client context PUBLIC AFB_error ctxTokenRefresh (AFB_clientCtx *clientCtx, AFB_request *request) { - int oldTnkValid; - const char *oldornew; uuid_t newuuid; if (clientCtx == NULL) return AFB_EMPTY;