// 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;
}
}
// 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;
AFB_clientCtx *clientCtx=NULL;
const char *uuid;
uuid_t newuuid;
- int ret;
if (request->config->token == NULL) return NULL;
// 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);
// 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;
}
// 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);
// 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;
// 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;