Guard against double-sending messages

parent 8875e4ae
......@@ -9,6 +9,7 @@ function (dukboot) {
var s = (id + 1) % n
print("id " + id + ": wrote " + buffer[0] + ', size=' + buffer.length);
dukboot.message.send(s, buffer);
if (id === 0) dukboot.message.send(s, buffer);
buffer = undefined;
while(buffer == undefined)
buffer = dukboot.message.read();
......
......@@ -62,6 +62,8 @@ duk_ret_t c_send_shared_buffer (duk_context *ctx) {
// int ptr = (int) duk_get_buffer_data(ctx, -1, &size);
duk_get_prop_string(ctx, -1, "\xFF" "messageBuffer");
messageBuffer* msg = duk_require_pointer(ctx, -1);
// Ensure user still has ownership of said buffer
if (msg->owner != omp_get_thread_num()) return duk_generic_error(ctx, "Thread attempted to (re)send a buffer it no longer owned.");
msg->owner = newOwner;
return 0;
}
......
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