mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-10 21:33:38 +00:00
Fixed crash/exception that could occur if you shutdown the agent while a websocket is connected
This commit is contained in:
@@ -4259,6 +4259,7 @@ ILibTransport_DoneState ILibDuktape_httpStream_webSocket_EncodedWriteSink(ILibDu
|
||||
void ILibDuktape_httpStream_webSocket_EncodedEndSink(ILibDuktape_DuplexStream *stream, void *user)
|
||||
{
|
||||
ILibDuktape_WebSocket_State *state = (ILibDuktape_WebSocket_State*)user;
|
||||
if (duk_ctx_shutting_down(state->ctx)) { return; }
|
||||
if (!state->closed) { ILibDuktape_DuplexStream_WriteEnd(state->decodedStream); }
|
||||
}
|
||||
void ILibDuktape_httpStream_webSocket_EncodedPauseSink_Chain(void *chain, void *user)
|
||||
@@ -4373,6 +4374,8 @@ void ILibDuktape_httpStream_webSocket_DecodedPauseSink_Chain(void *chain, void *
|
||||
void ILibDuktape_httpStream_webSocket_DecodedPauseSink(ILibDuktape_DuplexStream *sender, void *user)
|
||||
{
|
||||
ILibDuktape_WebSocket_State *state = (ILibDuktape_WebSocket_State*)user;
|
||||
if (state == NULL || state->encodedStream == NULL || state->encodedStream->writableStream == NULL) { return; } // ERROR
|
||||
|
||||
if (state->encodedStream->writableStream->pipedReadable_native != NULL && state->encodedStream->writableStream->pipedReadable_native->PauseHandler != NULL)
|
||||
{
|
||||
state->encodedStream->writableStream->pipedReadable_native->paused = 1;
|
||||
|
||||
@@ -825,6 +825,7 @@ duk_ret_t ILibDuktape_readableStream_unpipe(duk_context *ctx)
|
||||
int nargs = duk_get_top(ctx);
|
||||
int onlyItem = 0;
|
||||
ILibDuktape_readableStream *data;
|
||||
if (duk_ctx_shutting_down(ctx)) { return(0); }
|
||||
|
||||
duk_push_this(ctx); // [readable]
|
||||
duk_get_prop_string(ctx, -1, ILibDuktape_readableStream_RSPTRS); // [readable][ptrs]
|
||||
@@ -852,6 +853,8 @@ duk_ret_t ILibDuktape_readableStream_unpipe(duk_context *ctx)
|
||||
}
|
||||
sem_post(&(data->pipeLock));
|
||||
|
||||
if (duk_ctx_shutting_down(ctx) == 0)
|
||||
{
|
||||
if (nargs == 0 || onlyItem != 0)
|
||||
{
|
||||
// We need to pause first
|
||||
@@ -868,7 +871,7 @@ duk_ret_t ILibDuktape_readableStream_unpipe(duk_context *ctx)
|
||||
duk_put_prop_string(ctx, -2, "\xFF_Self"); // [immediate]
|
||||
if (nargs == 1) { duk_dup(ctx, 0); duk_put_prop_string(ctx, -2, "\xFF_w"); }
|
||||
duk_pop(ctx); // ...
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
duk_ret_t ILibDuktape_readableStream_isPaused(duk_context *ctx)
|
||||
|
||||
Reference in New Issue
Block a user