]> git.ipfire.org Git - thirdparty/util-linux.git/commit
tests: (lsfd) avoid race conditions (part 1)
authorMasatake YAMATO <yamato@redhat.com>
Thu, 31 Aug 2023 18:20:20 +0000 (03:20 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Sun, 3 Sep 2023 21:16:25 +0000 (06:16 +0900)
commit0fec4965f6c0f95b56df8ae67a77a1bdc4dda8a1
tree91b5d5b02d80fbd7fa8172d0214ddfd1029055db
parent618a88b51e8fd3489033517db9987a6231a8f1fe
tests: (lsfd) avoid race conditions (part 1)

For terminating test_mkfds process, the test cases
used SIGCONT. test_mkfds used pselect for waiting for the signal.
After receiving the signal test_mkfds exited.

There is a race condition in this logic. If a test case sends SIGCONT
to test_mkfds process before the process calls pselect, the signal
may be lost. As the result, test_mkfds keeps waiting forever in pselect.

This change replaces the code sending SIGCONT with writing to the pipe
connecting to the stdin of test_mkfds. test_mkfds also monitors
its stdin in the pselect call. Unlike the signal, the written bytes to
the pipe are queued.

This change doesn't touch tests/ts/lsfd/option-inet and option-summary
test cases. They don't use coproc. So fixing the race condition in the test
cases can be much complicated. I will make a dedicated pull request (part 2)
for them.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
40 files changed:
tests/ts/lsfd/column-ainodeclass
tests/ts/lsfd/column-deleted
tests/ts/lsfd/column-name
tests/ts/lsfd/column-source-with-root
tests/ts/lsfd/column-type
tests/ts/lsfd/column-xmode
tests/ts/lsfd/filter-floating-point-nums
tests/ts/lsfd/mkfds-bpf-prog
tests/ts/lsfd/mkfds-cdev-tun
tests/ts/lsfd/mkfds-directory
tests/ts/lsfd/mkfds-eventfd
tests/ts/lsfd/mkfds-eventpoll
tests/ts/lsfd/mkfds-inotify
tests/ts/lsfd/mkfds-mapped-packet-socket
tests/ts/lsfd/mkfds-mqueue
tests/ts/lsfd/mkfds-netlink-groups
tests/ts/lsfd/mkfds-netlink-protocol
tests/ts/lsfd/mkfds-netns
tests/ts/lsfd/mkfds-pidfd
tests/ts/lsfd/mkfds-ping
tests/ts/lsfd/mkfds-pipe-no-fork
tests/ts/lsfd/mkfds-raw
tests/ts/lsfd/mkfds-raw6
tests/ts/lsfd/mkfds-ro-block-device
tests/ts/lsfd/mkfds-ro-regular-file
tests/ts/lsfd/mkfds-rw-character-device
tests/ts/lsfd/mkfds-signalfd
tests/ts/lsfd/mkfds-socketpair
tests/ts/lsfd/mkfds-symlink
tests/ts/lsfd/mkfds-tcp
tests/ts/lsfd/mkfds-tcp6
tests/ts/lsfd/mkfds-timerfd
tests/ts/lsfd/mkfds-timerfd-alarm
tests/ts/lsfd/mkfds-udp
tests/ts/lsfd/mkfds-udp6
tests/ts/lsfd/mkfds-unix-dgram
tests/ts/lsfd/mkfds-unix-in-netns
tests/ts/lsfd/mkfds-unix-stream
tests/ts/lsfd/mkfds-unix-stream-requiring-sockdiag
tests/ts/lsfd/option-pid