diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ea05d4a..9270b56e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,7 +121,7 @@ jobs: build-alpine: name: Alpine Linux runs-on: ubuntu-latest - container: alpine:3.19 + container: alpine:3.21 strategy: fail-fast: false matrix: @@ -130,7 +130,7 @@ jobs: BUILDTYPE: ${{ matrix.buildType }} steps: - name: Prepare - run: apk add git build-base cmake curl-dev autoconf automake libtool texinfo linux-headers --update-cache + run: apk add git build-base cmake curl-dev autoconf automake libtool texinfo linux-headers libffi-dev --update-cache - uses: actions/checkout@v4 with: submodules: true @@ -138,7 +138,7 @@ jobs: with: node-version-file: '.nvmrc' - name: Build it - run: make VERBOSE=1 + run: make VERBOSE=1 USE_EXTERNAL_FFI=ON - name: Test it run: make test build-windows: diff --git a/src/curl-utils.c b/src/curl-utils.c index f4bf8fe6..ac5b9f87 100644 --- a/src/curl-utils.c +++ b/src/curl-utils.c @@ -165,11 +165,15 @@ static void uv__poll_cb(uv_poll_t *handle, int status, int events) { CHECK_NOT_NULL(qrt); int flags = 0; - if (events & UV_READABLE) { - flags |= CURL_CSELECT_IN; - } - if (events & UV_WRITABLE) { - flags |= CURL_CSELECT_OUT; + if (status != 0) { + flags |= CURL_CSELECT_ERR; + } else { + if (events & UV_READABLE) { + flags |= CURL_CSELECT_IN; + } + if (events & UV_WRITABLE) { + flags |= CURL_CSELECT_OUT; + } } int running_handles; @@ -197,12 +201,11 @@ static int curl__handle_socket(CURL *easy, curl_socket_t s, int action, void *us poll_ctx->qrt = qrt; poll_ctx->sockfd = s; poll_ctx->poll.data = poll_ctx; + curl_multi_assign(qrt->curl_ctx.curlm_h, s, (void *) poll_ctx); } else { poll_ctx = socketp; } - curl_multi_assign(qrt->curl_ctx.curlm_h, s, (void *) poll_ctx); - int events = 0; if (action != CURL_POLL_IN) { events |= UV_WRITABLE; @@ -222,8 +225,8 @@ static int curl__handle_socket(CURL *easy, curl_socket_t s, int action, void *us uv_close((uv_handle_t *) &poll_ctx->poll, uv__poll_close_cb); } break; - default: - abort(); + case CURL_POLL_NONE: + break; } return 0; diff --git a/src/vm.c b/src/vm.c index 4e27c170..151347f8 100644 --- a/src/vm.c +++ b/src/vm.c @@ -350,6 +350,16 @@ void TJS_FreeRuntime(TJSRuntime *qrt) { JS_FreeContext(qrt->ctx); JS_FreeRuntime(qrt->rt); + /* Destroy CURLM handle. */ + if (qrt->curl_ctx.curlm_h) { + curl_multi_cleanup(qrt->curl_ctx.curlm_h); + qrt->curl_ctx.curlm_h = NULL; + } + + /* Destroy WASM runtime. */ + m3_FreeEnvironment(qrt->wasm_ctx.env); + qrt->wasm_ctx.env = NULL; + /* Cleanup loop. All handles should be closed. */ int closed = 0; for (int i = 0; i < 5; i++) { @@ -368,16 +378,6 @@ void TJS_FreeRuntime(TJSRuntime *qrt) { (void) closed; #endif - /* Destroy CURLM handle. */ - if (qrt->curl_ctx.curlm_h) { - curl_multi_cleanup(qrt->curl_ctx.curlm_h); - qrt->curl_ctx.curlm_h = NULL; - } - - /* Destroy WASM runtime. */ - m3_FreeEnvironment(qrt->wasm_ctx.env); - qrt->wasm_ctx.env = NULL; - tjs__free(qrt); }