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

Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions src/share.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,29 +262,50 @@ share_cleanup_and_count_live_easies(CurlShareObject *self)

if (it && to_remove) {
PyObject *wr;
PyObject *obj = NULL;

while ((wr = PyIter_Next(it))) {
PyObject *obj = PyWeakref_GetObject(wr);
#if PY_VERSION_HEX >= 0x030D0000 /* Python 3.13+ */
int rc = PyWeakref_GetRef(wr, &obj);
// return -1 on error, 0 on dead object
// in either case, mark as removable and
// move to the next reference
if (rc < 1 || obj == NULL) {
Comment thread
tacaswell marked this conversation as resolved.
Outdated
PyList_Append(to_remove, wr);
Py_DECREF(wr);
continue;
}

#else
// will borrowed reference, None if object dead
obj = PyWeakref_GetObject(wr);
if (obj != Py_None) {
Comment thread
tacaswell marked this conversation as resolved.
CurlObject *easy = (CurlObject *)obj;
// If not None, real object, INCREF and carry on
Py_INCREF(obj);
} else {
// otherwise mark for removal and move to the next ref
PyList_Append(to_remove, wr);
Py_DECREF(wr);
continue;
}
#endif
CurlObject *easy = (CurlObject *)obj;

if (easy && easy->share == self) {
if (self->detach_on_close) {
curl_easy_setopt(easy->handle, CURLOPT_SHARE, NULL);
easy->share = NULL;
if (easy && easy->share == self) {
if (self->detach_on_close) {
curl_easy_setopt(easy->handle, CURLOPT_SHARE, NULL);
easy->share = NULL;

PyList_Append(to_remove, wr);
} else {
has_live += 1;
}
} else {
PyList_Append(to_remove, wr);
} else {
has_live += 1;
}
} else {
PyList_Append(to_remove, wr);
}

Py_DECREF(wr);
Py_DECREF(obj);
Comment thread
tacaswell marked this conversation as resolved.
}

Py_ssize_t i, n = PyList_GET_SIZE(to_remove);
Expand Down