Trying to avoid race conditions with automounters during and after -plug_test

This commit is contained in:
Thomas Schmitt 2019-12-10 16:45:32 +01:00
parent 1efa98ae40
commit ac018842da
4 changed files with 38 additions and 33 deletions

View File

@ -317,6 +317,10 @@ list_long() {
## Trying to find the desired device by watching plug-in effects
plug_in_watcher() {
# How long to wait for a first device to appear, how long to wait for more
wait_span_0=10
wait_span_1=5
found_devices=
echo >&2
echo "Caused by option -plug_test: Attempt to find the desired device" >&2
@ -339,26 +343,23 @@ plug_in_watcher() {
echo "Step 2:" >&2
echo "Please plug in the desired target device and then press the Enter key." >&2
read dummy
echo -n "Waiting up to 10 seconds for a new device to be listed ..." >&2
end_time="$(expr $(date +'%s') + 10)"
echo -n "Waiting up to $wait_span_0 seconds for a new device to be listed ..." >&2
end_time="$(expr $(date +'%s') + "$wait_span_0")"
while test $(date +'%s') -le "$end_time"
do
new_device_list=' '$(collect_devices)' '
if test "$old_device_list" = "$new_device_list"
then
sleep 1
echo -n '.' >&2
else
for i in $new_device_list
do
if echo "$old_device_list" | grep -F -v ' '"$i"' ' >/dev/null
if echo "$old_device_list $found_devices " | grep -F -v ' '"$i"' ' >/dev/null
then
echo " found: $i" >&2
found_devices="$found_devices $i"
end_time=$(expr $(date +'%s') + "$wait_span_1")
echo -n "Now waiting $wait_span_1 seconds to let it settle ..." >&2
fi
# Break the waiting loop
end_time=0
done
fi
sleep 1
echo -n '.' >&2
done
echo >&2
if test -z "$found_devices"
@ -388,8 +389,6 @@ plug_in_watcher() {
devs=$(echo -n $found_devices)
echo >&2
# Give new device a second to settle
sleep 1
return 0
}

View File

@ -220,7 +220,9 @@ Please plug in the desired target device and then press the Enter key.
.br
.br
Waiting up to 10 seconds for a new device to be listed ...
Waiting up to 10 seconds for a new device to be listed ... found: sdd
.br
Now waiting 5 seconds to let it settle .........
.br
Found and noted as desired device: sdd
.br

View File

@ -188,7 +188,9 @@ Step 2:
Please plug in the desired target device and then press the Enter key.
Waiting up to 10 seconds for a new device to be listed ...
Waiting up to 10 seconds for a new device to be listed ... found:
sdd
Now waiting 5 seconds to let it settle .........
Found and noted as desired device: sdd
@ -532,16 +534,16 @@ Node: Simplenames2792
Node: Listall3516
Node: Givendevices5089
Node: Plugtest6053
Node: Dowrite7893
Node: Unwise9008
Node: Reasons10520
Node: Options13101
Node: Examples15903
Node: Files16076
Node: Seealso16234
Node: Bugreport16400
Node: Legal16987
Node: CommandIdx17691
Node: ConceptIdx18811
Node: Dowrite7954
Node: Unwise9069
Node: Reasons10581
Node: Options13162
Node: Examples15964
Node: Files16137
Node: Seealso16295
Node: Bugreport16461
Node: Legal17048
Node: CommandIdx17752
Node: ConceptIdx18872

End Tag Table

View File

@ -322,7 +322,9 @@ Please plug in the desired target device and then press the Enter key.
@*
@*
Waiting up to 10 seconds for a new device to be listed ...
Waiting up to 10 seconds for a new device to be listed ... found: sdd
@*
Now waiting 5 seconds to let it settle .........
@*
Found and noted as desired device: sdd
@*