From: Fulup Ar Foll Date: Tue, 22 Dec 2015 19:15:13 +0000 (+0100) Subject: Does not compile X-Git-Tag: blowfish_2.0.1~321 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=1398adf363c182f25603f7d0c1ff52c5be8267b2;p=src%2Fapp-framework-binder.git Does not compile --- diff --git a/include/local-def.h b/include/local-def.h index 22a3608b..abbbd61f 100644 --- a/include/local-def.h +++ b/include/local-def.h @@ -181,6 +181,7 @@ typedef struct { int cacheTimeout; int apiTimeout; int cntxTimeout; // Client Session Context timeout + int pluginCount; // loaded plugins count AFB_aliasdir *aliasdir; // alias mapping for icons,apps,... } AFB_config; @@ -228,8 +229,8 @@ typedef struct { char token[37]; // short term authentication of remote client time_t timeStamp; // last time token was refresh int restfull; // client does not use cookie - void *ctx; // application specific context - AFB_plugin *plugin; // provide callback and easy access to plugin + void **ctx; // application specific context [one per plugin]] + AFB_plugin **plugins; // we need plugins reference to cleanup session outside of call context } AFB_clientCtx; // MHD_lookup_connection_value(connection, MHD_GET_ARGUMENT_KIND, "value"); @@ -239,9 +240,9 @@ typedef struct { char *api; AFB_PostRequest *post; json_object *jresp; - AFB_clientCtx *client; // needed because libmicrohttp cannot create an empty response - int restfull; // request is resfull [uuid token provided] - int errcode; // http error code + void *context; // Hold Client Context when using session + int restfull; // request is resfull [uuid token provided] + int errcode; // http error code sigjmp_buf checkPluginCall; // context save for timeout set/longjmp AFB_config *config; // plugin may need access to config struct MHD_Connection *connection; @@ -261,7 +262,6 @@ typedef struct { int fakemod; // respond to GET/POST request without interacting with sndboard int forceexit; // when autoconfig from script force exit before starting server AFB_plugin **plugins; // pointer to REST/API plugins - int pluginCount; // loaded plugins count magic_t magic; // Mime type file magic lib sigjmp_buf restartCkpt; // context save for restart set/longjmp } AFB_session; diff --git a/include/proto-def.h b/include/proto-def.h index df26ce1b..7f6fc065 100644 --- a/include/proto-def.h +++ b/include/proto-def.h @@ -47,7 +47,7 @@ PUBLIC AFB_error ctxTokenRefresh (AFB_request *request); PUBLIC AFB_error ctxTokenCreate (AFB_request *request); PUBLIC AFB_error ctxTokenCheck (AFB_request *request); PUBLIC AFB_error ctxTokenReset (AFB_request *request); -PUBLIC AFB_error ctxClientGet (AFB_request *request, AFB_plugin *plugin); +PUBLIC AFB_error ctxClientGet (AFB_request *request, AFB_session *session, int idx); PUBLIC void ctxStoreInit (int); diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index a04af66c..f87ca56e 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -259,21 +259,19 @@ - + - src - /usr/include/json-c include + /usr/include/json-c /usr/include/uuid + /usr/include/dbus-1.0 + /usr/lib64/dbus-1.0/include + /usr/include/alsa build/src HAVE_AUDIO_PLUGIN=1 PLUGIN_INSTALL_DIR="/usr/local/lib64/afb" - __PIC__=2 - __REGISTER_PREFIX__= - __USER_LABEL_PREFIX__= - __pic__=2 @@ -314,21 +312,19 @@ - + - src - /usr/include/json-c include + /usr/include/json-c /usr/include/uuid + /usr/include/dbus-1.0 + /usr/lib64/dbus-1.0/include + /usr/include/alsa build/src HAVE_AUDIO_PLUGIN=1 PLUGIN_INSTALL_DIR="/usr/local/lib64/afb" - __PIC__=2 - __REGISTER_PREFIX__= - __USER_LABEL_PREFIX__= - __pic__=2 @@ -366,21 +362,19 @@ - + - src + include /usr/include/json-c /usr/include/uuid - include + /usr/include/dbus-1.0 + /usr/lib64/dbus-1.0/include + /usr/include/alsa build/src HAVE_AUDIO_PLUGIN=1 PLUGIN_INSTALL_DIR="/usr/local/lib64/afb" - __PIC__=2 - __REGISTER_PREFIX__= - __USER_LABEL_PREFIX__= - __pic__=2 diff --git a/src/rest-api.c b/src/rest-api.c index 8146e144..69271398 100644 --- a/src/rest-api.c +++ b/src/rest-api.c @@ -116,7 +116,7 @@ STATIC AFB_error callPluginApi(AFB_plugin *plugin, AFB_request *request, void *c if (AFB_SESSION_NONE != plugin->apis[idx].session) { // add client context to request - if (ctxClientGet(request, plugin) != AFB_SUCCESS) { + if (ctxClientGet(request, idx) != AFB_SUCCESS) { request->errcode=MHD_HTTP_INSUFFICIENT_STORAGE; json_object_object_add(jcall, "status", json_object_new_string ("fail")); json_object_object_add(jcall, "info", json_object_new_string ("Client Session Context Full !!!")); @@ -621,5 +621,5 @@ void initPlugins(AFB_session *session) { // complete plugins and save them within current sessions session->plugins = RegisterJsonPlugins(plugins); - session->pluginCount = num; + session->config->pluginCount = num; } diff --git a/src/session.c b/src/session.c index 4877acf7..b5316d06 100644 --- a/src/session.c +++ b/src/session.c @@ -315,15 +315,16 @@ OnErrorExit: } - - // Free context [XXXX Should be protected again memory abort XXXX] STATIC void ctxUuidFreeCB (AFB_clientCtx *client) { // If application add a handle let's free it now if (client->ctx != NULL) { + int idx; + AFB_plugin **plugins = client->plugins; // Free client handle with a standard Free function, with app callback or ignore it + for (idx=0; idx < ) if (client->plugin->freeCtxCB == NULL) free (client->ctx); else if (client->plugin->freeCtxCB != (void*)-1) client->plugin->freeCtxCB(client); } @@ -435,7 +436,7 @@ PUBLIC int ctxStoreGarbage (const int timeout) { } // This function will return exiting client context or newly created client context -PUBLIC AFB_error ctxClientGet (AFB_request *request, AFB_plugin *plugin) { +PUBLIC AFB_error ctxClientGet (AFB_request *request, int idx) { static int cid=0; AFB_clientCtx *clientCtx=NULL; const char *uuid; @@ -473,13 +474,15 @@ PUBLIC AFB_error ctxClientGet (AFB_request *request, AFB_plugin *plugin) { } // 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 + if (clientCtx == NULL) { + clientCtx = calloc(1, sizeof(AFB_clientCtx)); // init NULL clientContext + clientCtx->ctx = cmalloc (1, request->config->pluginCount * (sizeof (void*))); + } + uuid_generate(newuuid); // create a new UUID uuid_unparse_lower(newuuid, clientCtx->uuid); clientCtx->cid=cid++; // simple application uniqueID - clientCtx->plugin = plugin; // provide plugin callbacks a hook to plugin - clientCtx->plugin; // provide plugin callbacks a hook to plugin - + // if table is full at 50% let's clean it up if(sessions.count > (sessions.max / 2)) ctxStoreGarbage(request->config->cntxTimeout); @@ -490,7 +493,7 @@ PUBLIC AFB_error ctxClientGet (AFB_request *request, AFB_plugin *plugin) { } // if (verbose) fprintf (stderr, "ctxClientGet New uuid=[%s] token=[%s] timestamp=%d\n", clientCtx->uuid, clientCtx->token, clientCtx->timeStamp); - request->client = clientCtx; + request->client = clientCtx->ctx[idx]; return(AFB_SUCCESS); }