Commit 671da487 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

Wait for Pub/Sub server to stop before returning

parent c9acd773
......@@ -3,7 +3,8 @@
static JSClassID jsDroneClassId;
static UA_Boolean pubsubRunning = true;
static UA_Boolean pubsubShouldRun = true;
static UA_Boolean pubsubExited = false;
static UA_UInt32 nbDrone;
static JSValueConst *droneObjectIdList;
......@@ -340,13 +341,14 @@ static JSValue js_run_pubsub(JSContext *ctx, JSValueConst this_val,
droneVariableArray, countof(droneVariableArray), id,
nbDrone, interval, init_node_id, get_drone_id,
pubsub_get_value, pubsub_update_coordinates,
&pubsubRunning);
&pubsubShouldRun);
} else {
res = subscribeOnly(&transportProfile, &networkAddressUrl,
droneVariableArray, countof(droneVariableArray), id,
nbDrone, interval, init_node_id, get_drone_id,
pubsub_print_coordinates, &pubsubRunning);
pubsub_print_coordinates, &pubsubShouldRun);
}
pubsubExited = true;
JS_FreeCString(ctx, ipv6);
JS_FreeCString(ctx, port);
......@@ -370,7 +372,9 @@ static JSValue js_stop_pubsub(JSContext *ctx, JSValueConst thisVal,
{
struct messageNode *current;
pubsubRunning = false;
pubsubShouldRun = false;
while(!pubsubExited)
sleep(1);
free(droneObjectIdList);
while (messageQueue.head != NULL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment