summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2019-01-05 21:08:33 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2019-02-05 09:58:01 +0100
commitec04e7de2d8068c804acff096e88e81b9cde70e7 (patch)
tree20690f313e222e92483c6018a268a8f1146589bd
parent5c23f4a29c9194fe7c16eb2a068f1d7e24bf57a7 (diff)
afb-proto-ws: Serialize incoming message
Enforce serialisation for a connection Bug-AGL: SPEC-2089 Change-Id: I0e673c1efe5ef2317bb28dc05891004b71f2b2ae Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-proto-ws.c7
-rw-r--r--src/afb-proto-ws.h2
-rw-r--r--src/afb-stub-ws.c4
3 files changed, 6 insertions, 7 deletions
diff --git a/src/afb-proto-ws.c b/src/afb-proto-ws.c
index 86112a32..1f7039e6 100644
--- a/src/afb-proto-ws.c
+++ b/src/afb-proto-ws.c
@@ -35,7 +35,6 @@
#include "afb-ws.h"
#include "afb-msg-json.h"
#include "afb-proto-ws.h"
-#include "jobs.h"
#include "fdev.h"
struct afb_proto_ws;
@@ -160,7 +159,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 **********************************/
@@ -347,7 +346,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;
}
@@ -1055,7 +1054,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;
}
diff --git a/src/afb-proto-ws.h b/src/afb-proto-ws.h
index b5f84e9e..d797cb6f 100644
--- a/src/afb-proto-ws.h
+++ b/src/afb-proto-ws.h
@@ -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);
diff --git a/src/afb-stub-ws.c b/src/afb-stub-ws.c
index a41a9b02..9bc52044 100644
--- a/src/afb-stub-ws.c
+++ b/src/afb-stub-ws.c
@@ -645,9 +645,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);
}
/*****************************************************/