fix context values
authorJosé Bollo <jose.bollo@iot.bzh>
Tue, 5 Apr 2016 11:18:21 +0000 (13:18 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Tue, 5 Apr 2016 11:18:21 +0000 (13:18 +0200)
Change-Id: I8a904fe7e0e895854729ae852b63c090f6c5bb5f
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
include/afb-req-itf.h
plugins/samples/ClientCtx.c
src/afb-apis.c

index a9b768d..8d869a6 100644 (file)
@@ -37,7 +37,7 @@ struct afb_req_itf {
 struct afb_req {
        const struct afb_req_itf *itf;
        void *data;
-       void *context;
+       void **context;
 };
 
 static inline struct afb_arg afb_req_get(struct afb_req req, const char *name)
index 3fa43ad..0ea8808 100644 (file)
@@ -75,7 +75,7 @@ static void myCreate (struct afb_req request)
     ctx->count = 0;
     ctx->abcd  = "SomeThingUseful";        
 
-    request.context = ctx;
+    *request.context = ctx;
     afb_req_success_f(request, NULL, "SUCCESS: create client context for plugin [%s]", handle->anythingYouWant);
 }
 
@@ -86,7 +86,7 @@ static void myCreate (struct afb_req request)
 static void myAction (struct afb_req request)
 {
     MyPluginHandleT  *handle = (MyPluginHandleT*) &global_handle;
-    MyClientContextT *ctx = (MyClientContextT*) request.context;
+    MyClientContextT *ctx = (MyClientContextT*) *request.context;
     
     // store something in our plugin private client context
     ctx->count++;
@@ -100,7 +100,7 @@ static void myAction (struct afb_req request)
 static void myClose (struct afb_req request)
 {
     MyPluginHandleT  *handle = (MyPluginHandleT*) &global_handle;
-    MyClientContextT *ctx = (MyClientContextT*) request.context;
+    MyClientContextT *ctx = (MyClientContextT*) *request.context;
     
     // store something in our plugin private client context
     ctx->count++;
index 8dfac51..55e68c9 100644 (file)
@@ -367,9 +367,8 @@ int afb_apis_handle(struct afb_req req, struct AFB_clientCtx *context, const cha
                        v = a->plugin->apis;
                        for (j = 0 ; v->name ; j++, v++) {
                                if (!strncasecmp(v->name, verb, lenverb) && !v->name[lenverb]) {
-                                       req.context = context->contexts[i];
+                                       req.context = &context->contexts[i];
                                        handle(req, v);
-                                       context->contexts[i] = req.context;
                                        return 1;
                                }
                        }