This is not a fix for the race conditions. It reduces the race window, but the fact that there's a race at all means that there's a more fundamental problem here. 'udevadm settle' only guarantees that currently-in-process events will be fully handled before it returns, but calling 'udevadm control --exit' should *already* provide this guarantee - and if it doesn't, all you've done is move the race, because when we do call 'udevadm control --exit' a few milliseconds later, any new events that are in process at *that* point will suffer from the same race.
We need to understand why 'udevadm control --exit' isn't sufficient and fix that at its source, because 'udevadm settle' doesn't give us the guarantees we need.
This is not a fix for the race conditions. It reduces the race window, but the fact that there's a race at all means that there's a more fundamental problem here. 'udevadm settle' only guarantees that currently- in-process events will be fully handled before it returns, but calling 'udevadm control --exit' should *already* provide this guarantee - and if it doesn't, all you've done is move the race, because when we do call 'udevadm control --exit' a few milliseconds later, any new events that are in process at *that* point will suffer from the same race.
We need to understand why 'udevadm control --exit' isn't sufficient and fix that at its source, because 'udevadm settle' doesn't give us the guarantees we need.