Close AsyncServerSocket sockets in reverse order
authorGiuseppe Ottaviano <ott@fb.com>
Wed, 30 Dec 2015 20:41:32 +0000 (12:41 -0800)
committerfacebook-github-bot-4 <folly-bot@fb.com>
Wed, 30 Dec 2015 21:20:21 +0000 (13:20 -0800)
commit99a7f38378ae291d89e12e66dca7866485fb45b6
tree465d5b5858b7be84f081138af74c300d39933907
parentf2a8b592861472bf47495c40519fdd778b420bc1
Close AsyncServerSocket sockets in reverse order

Summary:
When a large number of processes concurrently bind and close `AsyncServerSocket`s with `port=0` (for example in tests) binding the IPv4 socket on the same port bound with the IPv6 socket can currently fail, because sockets are closed in the same order as they are opened, which makes the following scenario possible:

```
P0: close IPv6 port
P1: open IPv6 port (succeed)
P1: open IPv4 port (FAIL)
P0: close IPv4 port
```

This diff reverses the closing order, and also fixes a couple of outdated comments.

Reviewed By: philippv

Differential Revision: D2795920

fb-gh-sync-id: 0b5157a56dfed84aed4a590c103050a2727847b3
folly/io/async/AsyncServerSocket.cpp