Backport patch to fix failing build with Python 3.9 (RhBug:1788918)
This commit is contained in:
parent
7193ef616a
commit
5b935af0c7
111
179.patch
Normal file
111
179.patch
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
From 34450c11255f7ae19ecda92f9bb4ff2b5adf498b Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
|
||||||
|
Date: Thu, 16 Jan 2020 16:36:11 +0100
|
||||||
|
Subject: [PATCH] Fix calling Python API without holding GIL (RhBug:1788918)
|
||||||
|
|
||||||
|
Librepo releases GIL for the download operations, but it wasn't taking
|
||||||
|
it again early enough in some callbacks where Python API is being called.
|
||||||
|
|
||||||
|
This commit moves taking the GIL in the callbacks to before any Python
|
||||||
|
API is called.
|
||||||
|
|
||||||
|
https://bugzilla.redhat.com/show_bug.cgi?id=1788918
|
||||||
|
---
|
||||||
|
librepo/python/handle-py.c | 6 ++++--
|
||||||
|
librepo/python/metadatatarget-py.c | 6 ++++--
|
||||||
|
librepo/python/packagetarget-py.c | 6 ++++--
|
||||||
|
3 files changed, 12 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/librepo/python/handle-py.c b/librepo/python/handle-py.c
|
||||||
|
index 28aad87..02615ad 100644
|
||||||
|
--- a/librepo/python/handle-py.c
|
||||||
|
+++ b/librepo/python/handle-py.c
|
||||||
|
@@ -142,6 +142,8 @@ fastestmirror_callback(void *data, LrFastestMirrorStages stage, void *ptr)
|
||||||
|
else
|
||||||
|
user_data = Py_None;
|
||||||
|
|
||||||
|
+ EndAllowThreads(self->state);
|
||||||
|
+
|
||||||
|
if (!ptr) {
|
||||||
|
pydata = Py_None;
|
||||||
|
} else {
|
||||||
|
@@ -159,7 +161,6 @@ fastestmirror_callback(void *data, LrFastestMirrorStages stage, void *ptr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- EndAllowThreads(self->state);
|
||||||
|
result = PyObject_CallFunction(self->fastestmirror_cb,
|
||||||
|
"(OlO)", user_data, (long) stage, pydata);
|
||||||
|
Py_XDECREF(result);
|
||||||
|
@@ -187,11 +188,12 @@ hmf_callback(void *data, const char *msg, const char *url, const char *metadata)
|
||||||
|
else
|
||||||
|
user_data = Py_None;
|
||||||
|
|
||||||
|
+ EndAllowThreads(self->state);
|
||||||
|
+
|
||||||
|
py_msg = PyStringOrNone_FromString(msg);
|
||||||
|
py_url = PyStringOrNone_FromString(url);
|
||||||
|
py_metadata = PyStringOrNone_FromString(metadata);
|
||||||
|
|
||||||
|
- EndAllowThreads(self->state);
|
||||||
|
result = PyObject_CallFunction(self->hmf_cb,
|
||||||
|
"(OOOO)", user_data, py_msg, py_url, py_metadata);
|
||||||
|
|
||||||
|
diff --git a/librepo/python/metadatatarget-py.c b/librepo/python/metadatatarget-py.c
|
||||||
|
index d5f4088..4cb67ad 100644
|
||||||
|
--- a/librepo/python/metadatatarget-py.c
|
||||||
|
+++ b/librepo/python/metadatatarget-py.c
|
||||||
|
@@ -142,10 +142,11 @@ metadatatarget_mirrorfailure_callback(void *data,
|
||||||
|
else
|
||||||
|
user_data = Py_None;
|
||||||
|
|
||||||
|
+ EndAllowThreads(self->state);
|
||||||
|
+
|
||||||
|
py_msg = PyStringOrNone_FromString(msg);
|
||||||
|
py_url = PyStringOrNone_FromString(url);
|
||||||
|
|
||||||
|
- EndAllowThreads(self->state);
|
||||||
|
result = PyObject_CallFunction(self->mirrorfailure_cb,
|
||||||
|
"(OOO)", user_data, py_msg, py_url);
|
||||||
|
|
||||||
|
@@ -205,9 +206,10 @@ metadatatarget_end_callback(void *data,
|
||||||
|
else
|
||||||
|
user_data = Py_None;
|
||||||
|
|
||||||
|
+ EndAllowThreads(self->state);
|
||||||
|
+
|
||||||
|
py_msg = PyStringOrNone_FromString(msg);
|
||||||
|
|
||||||
|
- EndAllowThreads(self->state);
|
||||||
|
result = PyObject_CallFunction(self->end_cb,
|
||||||
|
"(OiO)", user_data, status, py_msg);
|
||||||
|
Py_DECREF(py_msg);
|
||||||
|
diff --git a/librepo/python/packagetarget-py.c b/librepo/python/packagetarget-py.c
|
||||||
|
index 839ec8c..f5182dd 100644
|
||||||
|
--- a/librepo/python/packagetarget-py.c
|
||||||
|
+++ b/librepo/python/packagetarget-py.c
|
||||||
|
@@ -134,9 +134,10 @@ packagetarget_end_callback(void *data,
|
||||||
|
else
|
||||||
|
user_data = Py_None;
|
||||||
|
|
||||||
|
+ EndAllowThreads(self->state);
|
||||||
|
+
|
||||||
|
py_msg = PyStringOrNone_FromString(msg);
|
||||||
|
|
||||||
|
- EndAllowThreads(self->state);
|
||||||
|
result = PyObject_CallFunction(self->end_cb,
|
||||||
|
"(OiO)", user_data, status, py_msg);
|
||||||
|
Py_DECREF(py_msg);
|
||||||
|
@@ -185,10 +186,11 @@ packagetarget_mirrorfailure_callback(void *data,
|
||||||
|
else
|
||||||
|
user_data = Py_None;
|
||||||
|
|
||||||
|
+ EndAllowThreads(self->state);
|
||||||
|
+
|
||||||
|
py_msg = PyStringOrNone_FromString(msg);
|
||||||
|
py_url = PyStringOrNone_FromString(url);
|
||||||
|
|
||||||
|
- EndAllowThreads(self->state);
|
||||||
|
result = PyObject_CallFunction(self->mirrorfailure_cb,
|
||||||
|
"(OOO)", user_data, py_msg, py_url);
|
||||||
|
|
@ -27,13 +27,15 @@
|
|||||||
|
|
||||||
Name: librepo
|
Name: librepo
|
||||||
Version: 1.11.1
|
Version: 1.11.1
|
||||||
Release: 3%{?dist}
|
Release: 4%{?dist}
|
||||||
Summary: Repodata downloading library
|
Summary: Repodata downloading library
|
||||||
|
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
URL: https://github.com/rpm-software-management/librepo
|
URL: https://github.com/rpm-software-management/librepo
|
||||||
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
|
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
|
||||||
Patch01: 180.patch
|
Patch01: 180.patch
|
||||||
|
# fixes failing build with Python 3.9, bz1788918
|
||||||
|
Patch02: 179.patch
|
||||||
|
|
||||||
BuildRequires: cmake
|
BuildRequires: cmake
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
@ -190,6 +192,9 @@ popd
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Feb 10 2020 Ales Matej <amatej@fedoraproject.org> - 1.11.1-4
|
||||||
|
- Fix calling Python API without holding GIL (RhBug:1788918)
|
||||||
|
|
||||||
* Wed Feb 05 2020 Lukas Slebodnik <lslebodn@fedoraproject.org> - 1.11.1-3
|
* Wed Feb 05 2020 Lukas Slebodnik <lslebodn@fedoraproject.org> - 1.11.1-3
|
||||||
- Do not unref LrErr_Exception on exit (RhBug:1778854)
|
- Do not unref LrErr_Exception on exit (RhBug:1778854)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user