Make only 1 thread try to generate a delegate for an external special
remote at a time. This avoids concurrent remote initialization failing.
Avoid removing an emphemeral delegate when another process is also using
it. Rather than per-delegate locking, there is 1 lock per external
special remote, and while a shared lock is held, some ephemeral delgates
are in use, and other processes avoid removing them. This can leave one
process to remove ephemeral delegates that were created by another
process, but they will get removed in the end. This also makes the
removal crash safe.
Note that externalEphemeralDelegates is a list of remotes. Why not
just use Annex.remotes? Well, removeEphemeralDelegates is run as a
shutdown action, which means that with -J, it's run in the main Annex
state. But getDelegateRemote is run is a forked state, and modifies
Annex.remotes. Currently, mergeState does not merge in changes to
Annex.remotes, so that is not visible to the shutdown action.