Skip to content

Multiple calls to curl_multi_remove_handle with same easy handle no longer returns CURLM_OK #15844

Closed
@seragh

Description

@seragh

I did this

I have some code which calls curl_multi_remove_handle on application shutdown on an easy handle that might have already been removed on successfully doing it's work. Guess the original authors intention was to make sure curl gets shutdown cleanly irrespective.

Reproducer:

int main() {
    CURLM* mhandle = curl_multi_init();
    CURL* ehandle = curl_easy_init();

    curl_multi_add_handle(mhandle, ehandle);
    CURLMcode code1 = curl_multi_remove_handle(mhandle, ehandle);
    if (code1 != CURLM_OK) {
        printf("Failed first with %d\n", code1);
        return 1;
    }
    CURLMcode code2 = curl_multi_remove_handle(mhandle, ehandle);
    if (code2 != CURLM_OK) {
        printf("Failed second with %d\n", code2);
        return 1;
    }

    curl_easy_cleanup(ehandle);
    curl_multi_cleanup(mhandle);
}

Fails with "Failed second with 2", where in the past the second invocation returned CURLM_OK;

Bisecting points to ba235ab introducing this change.

I expected the following

Strictly speaking this could be considered a regression, but maybe you want to call it a legit bug fix. Let me know what your take is so I can decide how to go about it.

curl/libcurl version

8.10+

operating system

Linux, Debian (original reporter) and Gentoo (me)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions