]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests: rds: Disarm signal alarm on test completion
authorAllison Henderson <achender@kernel.org>
Thu, 7 May 2026 23:32:13 +0000 (16:32 -0700)
committerJakub Kicinski <kuba@kernel.org>
Sun, 10 May 2026 17:20:19 +0000 (10:20 -0700)
A race in stop_pcaps is possible if the test completes and then
times out while waiting for the tcpdump process to exit.  The
signal handler may fire again and needlessly call stop_pcap a
second time.  Fix this by disabling the alarm after normal
test completion.

Also if there are no tcpdump processes to wait on, stop_pcaps can
just exit.  This avoids misleading prints when there are no procs
to collect dumps from.

Signed-off-by: Allison Henderson <achender@kernel.org>
Link: https://patch.msgid.link/20260507233213.556182-4-achender@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/rds/test.py

index e1813e43fb4e1785b8ff9733b4a30fa3b7e360c2..6db60677923125522ec26cc90a6f5be9bb6b6039 100755 (executable)
@@ -77,6 +77,10 @@ def stop_pcaps():
     completes after the signal handler is fired.  List will be empty
     if logdir is not set
     """
+
+    if not tcpdump_procs:
+        return
+
     ksft_pr("Stopping network packet captures")
     while tcpdump_procs:
         proc = tcpdump_procs.pop()
@@ -279,6 +283,10 @@ for s in sockets:
                 pass
 
 ksft_pr(f"getsockopt(): {nr_success}/{nr_error}")
+
+# cancel timeout
+signal.alarm(0)
+
 stop_pcaps()
 
 # We're done sending and receiving stuff, now let's check if what