Commit e6d69248 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

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
parent d5f5bc4f
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <folly/ExceptionWrapper.h> #include <folly/ExceptionWrapper.h>
#include <folly/SocketAddress.h> #include <folly/SocketAddress.h>
#include <folly/experimental/TestUtil.h>
#include <folly/io/async/AsyncSSLSocket.h> #include <folly/io/async/AsyncSSLSocket.h>
#include <folly/io/async/AsyncServerSocket.h> #include <folly/io/async/AsyncServerSocket.h>
#include <folly/io/async/AsyncSocket.h> #include <folly/io/async/AsyncSocket.h>
...@@ -259,7 +260,9 @@ public: ...@@ -259,7 +260,9 @@ public:
wcb_->setSocket(socket_); wcb_->setSocket(socket_);
// Write back the same data. // Write back the same data.
folly::test::msvcSuppressAbortOnInvalidParams([&] {
socket_->write(wcb_, currentBuffer.buffer, len); socket_->write(wcb_, currentBuffer.buffer, len);
});
if (wcb_->state == STATE_FAILED) { if (wcb_->state == STATE_FAILED) {
setState(STATE_SUCCEEDED); setState(STATE_SUCCEEDED);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <folly/io/async/AsyncTimeout.h> #include <folly/io/async/AsyncTimeout.h>
#include <folly/io/async/EventBase.h> #include <folly/io/async/EventBase.h>
#include <folly/experimental/TestUtil.h>
#include <folly/io/IOBuf.h> #include <folly/io/IOBuf.h>
#include <folly/io/async/test/AsyncSocketTest.h> #include <folly/io/async/test/AsyncSocketTest.h>
#include <folly/io/async/test/Util.h> #include <folly/io/async/test/Util.h>
...@@ -2068,9 +2069,11 @@ TEST(AsyncSocketTest, DestroyCloseTest) { ...@@ -2068,9 +2069,11 @@ TEST(AsyncSocketTest, DestroyCloseTest) {
acceptedSocket.reset(); acceptedSocket.reset();
// Test that server socket was closed // Test that server socket was closed
folly::test::msvcSuppressAbortOnInvalidParams([&] {
ssize_t sz = read(fd, simpleBuf, simpleBufLength); ssize_t sz = read(fd, simpleBuf, simpleBufLength);
ASSERT_EQ(sz, -1); ASSERT_EQ(sz, -1);
ASSERT_EQ(errno, 9); ASSERT_EQ(errno, EBADF);
});
delete[] simpleBuf; delete[] simpleBuf;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment