hs-v3: With multiple SOCKS connection to the same .onion, don't trigger a descriptor fetch for each connection
This comes out of #23653 (moved) for a v3 only fix because a patch for v2 requires more refactoring.
We should only have one descriptor fetch at a time to an HSDir and not open one for each SOCKS connection. Because of how the client hsdir request cache works, you can't request the same .onion to the same HSDir inside a 15 minutes time frame (woa that is big). Thus, if we open 6 SOCKS requests and they all trigger a fetch, all HSDir are put in the cache and we can't query any of them while they are opened or until an error happened or until we can ultimately connect to the service.
Thus comes a bug where the 7th SOCKS connection (opened rapidly after the 6) will always fail because no HSDir can be used (#15937 (moved))
What we should do:
-
At each SOCKS connection, check if we have a pending directory fetch for the .onion and if so, wait on it.
-
On a fetch internal error, not allowed because of
FetchHidServDescriptors 0
or no more HSDir are usable, close all pending SOCKS connections instead of making them timeout (#23653 (moved)).