Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

Conversation

@swt2c
Copy link
Contributor

@swt2c swt2c commented Jan 8, 2026

Callbacks can be invoked during curl_easy_cleanup() and curl_multi_remove_handle() so make this possible in pycurl.

Fixes: #748
Fixes: #865

@swt2c swt2c force-pushed the allow_callbacks_during_close branch from 18c217f to bdd3566 Compare January 9, 2026 22:54
Callbacks can be invoked during curl_easy_cleanup() and
curl_multi_remove_handle() so make this possible in pycurl.

Fixes: pycurl#748
Fixes: pycurl#865
@swt2c swt2c force-pushed the allow_callbacks_during_close branch from 4df4e4b to 67fa3fe Compare January 11, 2026 18:57
self.curl.unsetopt(pycurl.CLOSESOCKETFUNCTION)

@util.min_libcurl(7, 21, 7)
def test_closesocketfunction_on_close(app):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a new test identical to this one, but deleting the Curl object and calling the gc.collect() and checking that the close callback was not called during dealloc?

assert(self != NULL);
assert(PyObject_IsInstance((PyObject *) self, (PyObject *) p_Curl_Type) == 1);
handle = self->handle;
self->handle = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not adding an additional parameter (e.g. cleanup) to util_curl_close to set the self->handle to NULL in case of dealloc:

/* Do not allow callbacks during dealloc */
if (cleanup != 0) {
    self->handle = NULL;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

curl.setopt(pycurl.CLOSESOCKETFUNCTION, ...) segfault Assertion failed: self->handle != NULL, file src/threadsupport.c, line 29

2 participants