From ce8de8236b96dc771d3af3094e04e797e75767af Mon Sep 17 00:00:00 2001 From: José Bollo Date: Fri, 5 May 2017 12:04:25 +0200 Subject: session: start to manage concurrency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5895fa14fcb496e71fba600994e7e454cf1d110b Signed-off-by: José Bollo --- bindings/samples/DemoContext.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'bindings/samples') 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); -- cgit 1.2.3-korg