Skip to content

Commit 9564a24

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

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
@@ -330,6 +330,16 @@ TJSRuntime *TJS_NewRuntimeInternal(bool is_worker, TJSRunOptions *options) {
330330
void TJS_FreeRuntime(TJSRuntime *qrt) {
331331
qrt->freeing = true;
332332

333+
/* Destroy CURLM handle. */
334+
if (qrt->curl_ctx.curlm_h) {
335+
curl_multi_cleanup(qrt->curl_ctx.curlm_h);
336+
qrt->curl_ctx.curlm_h = NULL;
337+
}
338+
339+
/* Destroy WASM runtime. */
340+
m3_FreeEnvironment(qrt->wasm_ctx.env);
341+
qrt->wasm_ctx.env = NULL;
342+
333343
/* Close all core loop handles. */
334344
uv_close((uv_handle_t *) &qrt->jobs.prepare, NULL);
335345
uv_close((uv_handle_t *) &qrt->jobs.idle, NULL);
@@ -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)