pub(crate) fn get_random_port() -> Result<u16>Expand description
Gets an open port. Can theoretically lead to a data race. There is no guarantee that the port will stay free between calling this function, and assigning it to some process. In practice, the Unix bind call assigns these randomly allocated ports semi-sequentially from the ephemeral range, in which there are 28000 to choose between. So this race condition probably definitely won’t be happening.
Bonus: If you were assigning them randomly, had the perfect storm of timing issues, and were looking for 100 ports, there’d only be 16.1% chance of two of your tests having the same birthday.