Skip to content

Commit b6f48a8

Browse files
committed
vm: destroy curl handle before destroying the loop
In case any final callbacks are fired.
1 parent 1e22d5f commit b6f48a8

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/vm.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,16 @@ void TJS_FreeRuntime(TJSRuntime *qrt) {
350350
JS_FreeContext(qrt->ctx);
351351
JS_FreeRuntime(qrt->rt);
352352

353+
/* Destroy CURLM handle. */
354+
if (qrt->curl_ctx.curlm_h) {
355+
curl_multi_cleanup(qrt->curl_ctx.curlm_h);
356+
qrt->curl_ctx.curlm_h = NULL;
357+
}
358+
359+
/* Destroy WASM runtime. */
360+
m3_FreeEnvironment(qrt->wasm_ctx.env);
361+
qrt->wasm_ctx.env = NULL;
362+
353363
/* Cleanup loop. All handles should be closed. */
354364
int closed = 0;
355365
for (int i = 0; i < 5; i++) {
@@ -368,16 +378,6 @@ void TJS_FreeRuntime(TJSRuntime *qrt) {
368378
(void) closed;
369379
#endif
370380

371-
/* Destroy CURLM handle. */
372-
if (qrt->curl_ctx.curlm_h) {
373-
curl_multi_cleanup(qrt->curl_ctx.curlm_h);
374-
qrt->curl_ctx.curlm_h = NULL;
375-
}
376-
377-
/* Destroy WASM runtime. */
378-
m3_FreeEnvironment(qrt->wasm_ctx.env);
379-
qrt->wasm_ctx.env = NULL;
380-
381381
tjs__free(qrt);
382382
}
383383

0 commit comments

Comments
 (0)