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 @@
#include <folly/ExceptionWrapper.h>
#include <folly/SocketAddress.h>
#include <folly/experimental/TestUtil.h>
#include <folly/io/async/AsyncSSLSocket.h>
#include <folly/io/async/AsyncServerSocket.h>
#include <folly/io/async/AsyncSocket.h>
......@@ -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);
......
......@@ -22,6 +22,7 @@
#include <folly/io/async/AsyncTimeout.h>
#include <folly/io/async/EventBase.h>
#include <folly/experimental/TestUtil.h>
#include <folly/io/IOBuf.h>
#include <folly/io/async/test/AsyncSocketTest.h>
#include <folly/io/async/test/Util.h>
......@@ -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;
}
......
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