From 25d62850ce8a420600194009a7257148c43cc5f8 Mon Sep 17 00:00:00 2001 From: Zhaozhong Ni Date: Thu, 20 Dec 2018 09:51:26 -0800 Subject: test: deflake socket_inet_loopback. PiperOrigin-RevId: 226350590 Change-Id: Idff080705f644f8f78ce92b53c77eecc37e002e7 --- test/syscalls/linux/socket_inet_loopback.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/syscalls/linux/socket_inet_loopback.cc b/test/syscalls/linux/socket_inet_loopback.cc index 7bdbd7797..17a46e149 100644 --- a/test/syscalls/linux/socket_inet_loopback.cc +++ b/test/syscalls/linux/socket_inet_loopback.cc @@ -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()); -- cgit v1.2.3