summaryrefslogtreecommitdiffstats
path: root/debian/patches/upstream/lslocks-don-t-abort-gathering-per-process-information-eve.patch
blob: 59abf3479a568e862f481dcdabf12070c73f4489 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
From: Masatake YAMATO <yamato@redhat.com>
Date: Sat, 13 Apr 2024 03:59:39 +0900
Subject: lslocks: don't abort gathering per-process information even if
 opening a /proc/[0-9]* fails

If a process ($pid) taking a lock is gone while running lslocks,
gathering per-process information for the process may fail in opening
/proc/$pid. Though lslocks should work with incomplete information,
the original code stopped gathering per-process information for the
other processes.

As a result of the original behavior, tests/ts/lslocks/lslocks really
failed in an environment where multiple test cases ran simultaneously.

Close #2624 again.
See also #2633.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
(cherry picked from commit 20df923cc3d2da12a5296223c3ff0de7484cc587)
---
 misc-utils/lslocks.c     |  6 ++----
 tests/ts/lslocks/lslocks | 11 -----------
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c
index 3d70b04..60f6595 100644
--- a/misc-utils/lslocks.c
+++ b/misc-utils/lslocks.c
@@ -513,10 +513,8 @@ static int get_pids_locks(void *locks, void (*add_lock)(void *, struct lock *))
 		if (procfs_dirent_get_pid(d, &pid) != 0)
 			continue;
 
-		if (procfs_process_init_path(pc, pid) != 0) {
-			rc = -1;
-			break;
-		}
+		if (procfs_process_init_path(pc, pid) != 0)
+			continue;
 
 		if (procfs_process_get_cmdname(pc, buf, sizeof(buf)) <= 0)
 			continue;
diff --git a/tests/ts/lslocks/lslocks b/tests/ts/lslocks/lslocks
index 912fac8..a9ef69a 100755
--- a/tests/ts/lslocks/lslocks
+++ b/tests/ts/lslocks/lslocks
@@ -53,14 +53,6 @@ OFD_METHODS=(
     lease-w
 )
 
-SLEEP()
-{
-    # It appears that there is a time lag between locking and its
-    # visibility in /proc/locks.  See the unstbale results of errors I
-    # observed in https://github.com/util-linux/util-linux/pull/2629.
-    sleep 1
-}
-
 DFD=18
 COLS_WITH_HOLDERS=COMMAND,TYPE,SIZE,MODE,START,END,HOLDERS
 run_lslocks()
@@ -71,8 +63,6 @@ run_lslocks()
 	rm -f "${FILE}"
 	coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" lock=$m; }
 	if read -r -u "${MKFDS[0]}" PID; then
-	    SLEEP
-
 	    "$TS_CMD_LSLOCKS" ${OPTS} --pid "${PID}" -o "${COLS}"
 	    echo "# $m + ${COLS} + ${OPTS}": $?
 	    "$TS_CMD_LSLOCKS" ${OPTS} --pid "${PID}" -o PATH | sed -e 's#.*\('"$FILE0"'\)--[0-9]\+ *$#\1#'
@@ -91,7 +81,6 @@ run_lslocks_with_co_holders()
     {
 	rm -f "${FILE}"
 	coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" lock=$m dupfd=$DFD; }
-	SLEEP
 	if read -r -u "${MKFDS[0]}" PID; then
 	    "$TS_CMD_LSLOCKS" ${OPTS} --pid "${PID}" -o "${COLS_WITH_HOLDERS}" | sed -e "s/${PID},/1,/g"
 	    echo "# $m + ${COLS_WITH_HOLDERS} + ${OPTS}": ${PIPESTATUS[0]}