diff options
-rw-r--r-- | meta/recipes-devtools/dnf/dnf/0001-lock.py-fix-Exception-handling.patch | 62 | ||||
-rw-r--r-- | meta/recipes-devtools/dnf/dnf_4.19.0.bb | 1 |
2 files changed, 63 insertions, 0 deletions
diff --git a/meta/recipes-devtools/dnf/dnf/0001-lock.py-fix-Exception-handling.patch b/meta/recipes-devtools/dnf/dnf/0001-lock.py-fix-Exception-handling.patch new file mode 100644 index 0000000000..6bffe9af0a --- /dev/null +++ b/meta/recipes-devtools/dnf/dnf/0001-lock.py-fix-Exception-handling.patch | |||
@@ -0,0 +1,62 @@ | |||
1 | From 3881757eabfde2ff54400ab127b106ab085d83f0 Mon Sep 17 00:00:00 2001 | ||
2 | From: Changqing Li <changqing.li@windriver.com> | ||
3 | Date: Wed, 13 Mar 2024 11:22:05 +0800 | ||
4 | Subject: [PATCH] lock.py: fix Exception handling | ||
5 | |||
6 | Before, when logdir is not writable, _try_lock will raise an Exception | ||
7 | like "Permission denied: '/var/log/log_lock.pid'", and in this case, | ||
8 | _unlock_thread will not be called and the variable count will not be | ||
9 | handled, it maybe cause log_lock.pid not be deleted in case like [1]. | ||
10 | |||
11 | For [1], it is an cross compile case, when dnf install some packages to | ||
12 | rootfs, seems like some threads don't do chroot like work, some threads | ||
13 | do chroot like work. so for the threads don't do chroot, "Permission denied" | ||
14 | Exception happend, for the threads that do chroot, log_lock.pid will be | ||
15 | created under installroot/var/log/log_lock.pid, since variable count not | ||
16 | handled correct before, log_lock.pid may not be deleted correctly. | ||
17 | |||
18 | So fixed like this, if _try_lock raise Exception, _unlock_thread first, | ||
19 | then raise the Exception. | ||
20 | |||
21 | [1] https://github.com/rpm-software-management/dnf/issues/1963 | ||
22 | |||
23 | Upstream-Status: Submitted [ https://github.com/rpm-software-management/dnf/pull/2065 ] | ||
24 | |||
25 | Signed-off-by: Changqing Li <changqing.li@windriver.com> | ||
26 | --- | ||
27 | dnf/lock.py | 12 ++++++++++-- | ||
28 | 1 file changed, 10 insertions(+), 2 deletions(-) | ||
29 | |||
30 | diff --git a/dnf/lock.py b/dnf/lock.py | ||
31 | index 6817aac9..5718062a 100644 | ||
32 | --- a/dnf/lock.py | ||
33 | +++ b/dnf/lock.py | ||
34 | @@ -128,7 +128,11 @@ class ProcessLock(object): | ||
35 | self._lock_thread() | ||
36 | prev_pid = -1 | ||
37 | my_pid = os.getpid() | ||
38 | - pid = self._try_lock(my_pid) | ||
39 | + try: | ||
40 | + pid = self._try_lock(my_pid) | ||
41 | + except Exception: | ||
42 | + self._unlock_thread() | ||
43 | + raise | ||
44 | while pid != my_pid: | ||
45 | if pid != -1: | ||
46 | if not self.blocking: | ||
47 | @@ -140,7 +144,11 @@ class ProcessLock(object): | ||
48 | logger.info(msg) | ||
49 | prev_pid = pid | ||
50 | time.sleep(1) | ||
51 | - pid = self._try_lock(my_pid) | ||
52 | + try: | ||
53 | + pid = self._try_lock(my_pid) | ||
54 | + except Exception: | ||
55 | + self._unlock_thread() | ||
56 | + raise | ||
57 | |||
58 | def __exit__(self, *exc_args): | ||
59 | if self.count == 1: | ||
60 | -- | ||
61 | 2.25.1 | ||
62 | |||
diff --git a/meta/recipes-devtools/dnf/dnf_4.19.0.bb b/meta/recipes-devtools/dnf/dnf_4.19.0.bb index 784d7a94b3..184dbea963 100644 --- a/meta/recipes-devtools/dnf/dnf_4.19.0.bb +++ b/meta/recipes-devtools/dnf/dnf_4.19.0.bb | |||
@@ -15,6 +15,7 @@ SRC_URI = "git://github.com/rpm-software-management/dnf.git;branch=master;protoc | |||
15 | file://0029-Do-not-set-PYTHON_INSTALL_DIR-by-running-python.patch \ | 15 | file://0029-Do-not-set-PYTHON_INSTALL_DIR-by-running-python.patch \ |
16 | file://0030-Run-python-scripts-using-env.patch \ | 16 | file://0030-Run-python-scripts-using-env.patch \ |
17 | file://0001-set-python-path-for-completion_helper.patch \ | 17 | file://0001-set-python-path-for-completion_helper.patch \ |
18 | file://0001-lock.py-fix-Exception-handling.patch \ | ||
18 | " | 19 | " |
19 | 20 | ||
20 | SRC_URI:append:class-native = "file://0001-dnf-write-the-log-lock-to-root.patch" | 21 | SRC_URI:append:class-native = "file://0001-dnf-write-the-log-lock-to-root.patch" |