dotcloud/docker — pull request #5925 by erikh (2014-05-20 06:12:37+00:00)
Title: portallocator: combine find port / add port semantics, with locking.

sorry for the dirty whitespace in this patch.

This locking allows the port allocator to perform the port allocation atomically; before there was the opportunity for findNextPort to race against itself from a variety of usage scenarios.

Tested with docker-stress:

```
$ sudo ./docker-stress -d /home/erikh/docker/bundles/0.11.1-dev/binary/docker-0.11.1-dev -c 50
```

And `docker -d` running against a recent build of master.

This potentially resolves #5738