aboutsummaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-05-05 12:04:25 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-05-05 12:12:05 +0200
commitce8de8236b96dc771d3af3094e04e797e75767af (patch)
tree37bf561a8a183aea5fa035200414f3575ad24121 /bindings
parente97aa93b02793018d7d9cad1582748b02493dad2 (diff)
session: start to manage concurrency
Change-Id: I5895fa14fcb496e71fba600994e7e454cf1d110b Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'bindings')
-rw-r--r--bindings/samples/DemoContext.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/bindings/samples/DemoContext.c b/bindings/samples/DemoContext.c
index 66dc6ccf..26677949 100644
--- a/bindings/samples/DemoContext.c
+++ b/bindings/samples/DemoContext.c
@@ -67,6 +67,10 @@ static void myAction (struct afb_req request)
{
MyClientContextT *ctx = (MyClientContextT*) afb_req_context_get(request);
+ if (!ctx) {
+ afb_req_fail(request, "invalid-state", "Can't perform action");
+ return;
+ }
// store something in our plugin private client context
ctx->count++;
afb_req_success_f(request, NULL, "SUCCESS: plugin [%s] Check=[%d]\n", ctx->abcd, ctx->count);
@@ -80,6 +84,10 @@ static void myClose (struct afb_req request)
{
MyClientContextT *ctx = (MyClientContextT*) afb_req_context_get(request);
+ if (!ctx) {
+ afb_req_success(request, NULL, NULL);
+ return;
+ }
// store something in our plugin private client context
ctx->count++;
afb_req_success_f(request, NULL, "SUCCESS: plugin [%s] Close=[%d]\n", ctx->abcd, ctx->count);