Auto merge of #5570 - alexcrichton:fix-deadlock, r=matklad
authorbors <bors@rust-lang.org>
Mon, 28 May 2018 09:34:35 +0000 (09:34 +0000)
committerbors <bors@rust-lang.org>
Mon, 28 May 2018 09:34:35 +0000 (09:34 +0000)
Fix an issue of deadlock in Cargo

Currently Cargo can deadlock itself via file locks in somewhat obscure
scenarios. One way to trigger this scenario is by causing the index to fail
being created, for example through an invalid `init.templatedir` configuration.

This commit takes the strategy of solving two bugs:

* First, the deadlock is fixed. This is done by manually ensuring that the
  current deadlock doesn't happen by scheduling cached work to happen outside
  the scope of a lock.
* Second, the initialization of the registry's index is fixed. We turn off the
  usage of external templates as we don't want to use them for this internally
  managed repository anyway.

Closes #5551


Trivial merge