dotcloud/docker — pull request #1623 by mhennings (2013-08-22 11:30:12+00:00)
Title: Fix race conditions in parallel pull

There are some race conditions in parallel pull:

- In case of error the server crashes sometimes (see #1592)
- During parallel pull of a repostiory it can happen that the same layer
is pulled more than once, so that two writing processes fetch and extract the same layer. This causes mostly load but sometimes errors.

To fix this I have extended the locking code to
- avoid multiple pulls of the same image
- avoid multiple pulls of the same layer

If an error occurs the other layers are awaited before returning as leaving
the scope before the go routines leave causes crashes of the server sometimes
if the download status is updated while the http stream is already closed

Beside this I have extended status display.