diff --git a/src/ssb.c b/src/ssb.c index 6c084d14..6e315930 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -2806,6 +2806,16 @@ void tf_ssb_destroy(tf_ssb_t* ssb) uv_run(ssb->loop, UV_RUN_NOWAIT); + if (ssb->own_context) + { + if (!ssb->quiet) + { + tf_printf("closing ssb context\n"); + } + JS_FreeContext(ssb->context); + JS_FreeRuntime(ssb->runtime); + ssb->own_context = false; + } if (ssb->loop == &ssb->own_loop) { if (!ssb->quiet) @@ -2822,16 +2832,6 @@ void tf_ssb_destroy(tf_ssb_t* ssb) { tf_printf("uv loop closed.\n"); } - if (ssb->own_context) - { - if (!ssb->quiet) - { - tf_printf("closing ssb context\n"); - } - JS_FreeContext(ssb->context); - JS_FreeRuntime(ssb->runtime); - ssb->own_context = false; - } while (ssb->broadcasts) { tf_ssb_broadcast_t* broadcast = ssb->broadcasts;