afb-proto-ws: Serialize incoming message 23/19523/2
authorJosé Bollo <jose.bollo@iot.bzh>
Sat, 5 Jan 2019 20:08:33 +0000 (21:08 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Wed, 16 Jan 2019 21:32:25 +0000 (22:32 +0100)
Enforce serialisation for a connection

Bug-AGL: SPEC-2089

Change-Id: Id9f261b7cc02fda78922dc511856c34b7c5bf56d
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/afb-proto-ws.c
src/afb-proto-ws.h
src/afb-stub-ws.c

index f74869c..f407086 100644 (file)
@@ -35,7 +35,6 @@
 #include "afb-ws.h"
 #include "afb-msg-json.h"
 #include "afb-proto-ws.h"
-#include "jobs.h"
 #include "fdev.h"
 #include "verbose.h"
 
@@ -161,7 +160,7 @@ struct afb_proto_ws
        void (*on_hangup)(void *closure);
 
        /* queuing facility for processing messages */
-       int (*queuing)(void (*process)(int s, void *c), void *closure);
+       int (*queuing)(struct afb_proto_ws *proto, void (*process)(int s, void *c), void *closure);
 };
 
 /******************* streaming objects **********************************/
@@ -348,7 +347,7 @@ static void queue_message_processing(struct afb_proto_ws *protows, char *data, s
                        binary->rb.head = data;
                        binary->rb.end = data + size;
                        if (!protows->queuing
-                        || protows->queuing(processing, binary) < 0)
+                        || protows->queuing(protows, processing, binary) < 0)
                                processing(0, binary);
                        return;
                }
@@ -1068,7 +1067,7 @@ void afb_proto_ws_on_hangup(struct afb_proto_ws *protows, void (*on_hangup)(void
        protows->on_hangup = on_hangup;
 }
 
-void afb_proto_ws_set_queuing(struct afb_proto_ws *protows, int (*queuing)(void (*)(int,void*), void*))
+void afb_proto_ws_set_queuing(struct afb_proto_ws *protows, int (*queuing)(struct afb_proto_ws*, void (*)(int,void*), void*))
 {
        protows->queuing = queuing;
 }
index b5f84e9..d797cb6 100644 (file)
@@ -61,7 +61,7 @@ extern int afb_proto_ws_is_server(struct afb_proto_ws *protows);
 extern void afb_proto_ws_hangup(struct afb_proto_ws *protows);
 
 extern void afb_proto_ws_on_hangup(struct afb_proto_ws *protows, void (*on_hangup)(void *closure));
-extern void afb_proto_ws_set_queuing(struct afb_proto_ws *protows, int (*queuing)(void (*)(int,void*), void*));
+extern void afb_proto_ws_set_queuing(struct afb_proto_ws *protows, int (*queuing)(struct afb_proto_ws *, void (*)(int,void*), void*));
 
 
 extern int afb_proto_ws_client_call(struct afb_proto_ws *protows, const char *verb, struct json_object *args, const char *sessionid, void *request, const char *user_creds);
index 5dfacb7..7ec2d63 100644 (file)
@@ -646,9 +646,9 @@ static void on_hangup(void *closure)
        }
 }
 
-static int enqueue_processing(void (*callback)(int signum, void* arg), void *arg)
+static int enqueue_processing(struct afb_proto_ws *proto, void (*callback)(int signum, void* arg), void *arg)
 {
-       return jobs_queue(NULL, 0, callback, arg);
+       return jobs_queue(proto, 0, callback, arg);
 }
 
 /*****************************************************/