1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-06 02:23:59 +00:00

Added ability to Save/Restore handle wait state

Fixed edge case that could cause a connection to resume twice
This commit is contained in:
Bryan Roe
2020-05-20 12:05:38 -07:00
parent f2d63ea116
commit 16a2f437c3
4 changed files with 102 additions and 2 deletions

View File

@@ -701,6 +701,8 @@ duk_ret_t ILibDuktape_readableStream_pipe(duk_context *ctx)
duk_call_method(ctx, 2); duk_pop(ctx); // ...
if (rstream->paused != 0)
{
rstream->paused = 0; // Set state now, so nobody tries to resume before we can finish piping
// We are paused, so we should yield and resume... We yield, so in case the user tries to chain multiple pipes, it will chain first
rstream->resumeImmediate = ILibDuktape_Immediate(ctx, (void*[]) { rstream, duk_get_heapptr(ctx, 0) }, 1, ILibDuktape_ReadableStream_pipe_ResumeLater);
duk_push_heapptr(ctx, rstream->resumeImmediate); // [immediate]