From e6d69248da39a1618352a2040f6d26f95ff86196 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Wed, 23 Nov 2016 10:43:24 -0800 Subject: [PATCH] Suppress some aborts in debug mode when using already closed file descriptors Summary: The helper exists because MSVC is a pain in this regard, so use it. Reviewed By: yfeldblum Differential Revision: D4224037 fbshipit-source-id: 6c6415877785f13ea91618a3042f2470dccd08c1 --- folly/io/async/test/AsyncSSLSocketTest.h | 5 ++++- folly/io/async/test/AsyncSocketTest2.cpp | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/folly/io/async/test/AsyncSSLSocketTest.h b/folly/io/async/test/AsyncSSLSocketTest.h index 7ae4aeb5..65c62cb0 100644 --- a/folly/io/async/test/AsyncSSLSocketTest.h +++ b/folly/io/async/test/AsyncSSLSocketTest.h @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -259,7 +260,9 @@ public: wcb_->setSocket(socket_); // Write back the same data. - socket_->write(wcb_, currentBuffer.buffer, len); + folly::test::msvcSuppressAbortOnInvalidParams([&] { + socket_->write(wcb_, currentBuffer.buffer, len); + }); if (wcb_->state == STATE_FAILED) { setState(STATE_SUCCEEDED); diff --git a/folly/io/async/test/AsyncSocketTest2.cpp b/folly/io/async/test/AsyncSocketTest2.cpp index 02650418..36ccc305 100644 --- a/folly/io/async/test/AsyncSocketTest2.cpp +++ b/folly/io/async/test/AsyncSocketTest2.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -2068,9 +2069,11 @@ TEST(AsyncSocketTest, DestroyCloseTest) { acceptedSocket.reset(); // Test that server socket was closed - ssize_t sz = read(fd, simpleBuf, simpleBufLength); - ASSERT_EQ(sz, -1); - ASSERT_EQ(errno, 9); + folly::test::msvcSuppressAbortOnInvalidParams([&] { + ssize_t sz = read(fd, simpleBuf, simpleBufLength); + ASSERT_EQ(sz, -1); + ASSERT_EQ(errno, EBADF); + }); delete[] simpleBuf; } -- 2.34.1