test: deflake socket_inet_loopback.

PiperOrigin-RevId: 226350590
Change-Id: Idff080705f644f8f78ce92b53c77eecc37e002e7
This commit is contained in:
Zhaozhong Ni 2018-12-20 09:51:26 -08:00 committed by Shentubot
parent 86c9bd2547
commit 25d62850ce
1 changed files with 6 additions and 1 deletions

View File

@ -185,7 +185,12 @@ TEST_P(SocketInetLoopbackTest, TCP) {
SyscallSucceeds());
// Accept the connection.
ASSERT_NO_ERRNO_AND_VALUE(Accept(listen_fd.get(), nullptr, nullptr));
//
// We have to assign a name to the accepted socket, as unamed temporary
// objects are destructed upon full evaluation of the expression it is in,
// potentially causing the connecting socket to fail to shutdown properly.
auto accepted =
ASSERT_NO_ERRNO_AND_VALUE(Accept(listen_fd.get(), nullptr, nullptr));
ASSERT_THAT(shutdown(listen_fd.get(), SHUT_RDWR), SyscallSucceeds());