Commit 31bd58d8 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook GitHub Bot

Fix async socket test (stack-use-after-scope)

Summary: Fix async socket test (stack-use-after-scope)

Reviewed By: andriigrynenko

Differential Revision: D24650836

fbshipit-source-id: 795fb71770612a409195d93216c7c5e129bea605
parent c3fe90d8
...@@ -1161,6 +1161,7 @@ TEST(AsyncSocketTest, WriteErrorCallbackBytesWritten) { ...@@ -1161,6 +1161,7 @@ TEST(AsyncSocketTest, WriteErrorCallbackBytesWritten) {
std::thread senderThread([&]() { senderEvb.loopForever(); }); std::thread senderThread([&]() { senderEvb.loopForever(); });
ConnCallback ccb; ConnCallback ccb;
WriteCallback wcb;
std::shared_ptr<AsyncSocket> socket; std::shared_ptr<AsyncSocket> socket;
senderEvb.runInEventBaseThreadAndWait([&]() { senderEvb.runInEventBaseThreadAndWait([&]() {
...@@ -1175,8 +1176,6 @@ TEST(AsyncSocketTest, WriteErrorCallbackBytesWritten) { ...@@ -1175,8 +1176,6 @@ TEST(AsyncSocketTest, WriteErrorCallbackBytesWritten) {
constexpr size_t kSendSize = 100 * 1024; constexpr size_t kSendSize = 100 * 1024;
auto const sendBuf = std::vector<char>(kSendSize, 'a'); auto const sendBuf = std::vector<char>(kSendSize, 'a');
WriteCallback wcb;
senderEvb.runInEventBaseThreadAndWait( senderEvb.runInEventBaseThreadAndWait(
[&]() { socket->write(&wcb, sendBuf.data(), kSendSize); }); [&]() { socket->write(&wcb, sendBuf.data(), kSendSize); });
...@@ -1212,6 +1211,7 @@ TEST(AsyncSocketTest, WriteErrorCallbackBytesWritten) { ...@@ -1212,6 +1211,7 @@ TEST(AsyncSocketTest, WriteErrorCallbackBytesWritten) {
senderEvb.terminateLoopSoon(); senderEvb.terminateLoopSoon();
senderThread.join(); senderThread.join();
socket.reset();
ASSERT_EQ(STATE_FAILED, wcb.state); ASSERT_EQ(STATE_FAILED, wcb.state);
ASSERT_LE(kMinExpectedBytesWritten, wcb.bytesWritten); ASSERT_LE(kMinExpectedBytesWritten, wcb.bytesWritten);
......
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