Fix potential double close() on exception v2016.12.05.00
authorAmir Shalem <amirshalem@fb.com>
Sun, 4 Dec 2016 19:15:34 +0000 (11:15 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Sun, 4 Dec 2016 19:23:52 +0000 (11:23 -0800)
Summary:
Fix potential double close() on exception when SO_REUSEPORT fails.
The fd will be closed twice, once by close() and second by the scope guard above.

Reviewed By: yfeldblum

Differential Revision: D4272300

fbshipit-source-id: a163be822d7522cadb9dc3c3eddca10df453de14

folly/io/async/AsyncUDPSocket.cpp

index 0cf9d8cfa0c3ca410ba7ef6f02c6d8f8b1fffeba..082f7994cb0af8f2ddc0318cb195853d5f04e18a 100644 (file)
@@ -88,7 +88,6 @@ void AsyncUDPSocket::bind(const folly::SocketAddress& address) {
                    SO_REUSEPORT,
                    &value,
                    sizeof(value)) != 0) {
-      ::close(socket);
       throw AsyncSocketException(AsyncSocketException::NOT_OPEN,
                                 "failed to put socket in reuse_port mode",
                                 errno);