[Lldb-commits] [PATCH] D41008: MainLoop: avoid infinite loop when pty slave gets closed
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Dec 11 01:34:01 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL320345: MainLoop: avoid infinite loop when pty slave gets closed (authored by labath).
Repository:
rL LLVM
https://reviews.llvm.org/D41008
Files:
lldb/trunk/source/Host/common/MainLoop.cpp
lldb/trunk/unittests/Host/MainLoopTest.cpp
Index: lldb/trunk/unittests/Host/MainLoopTest.cpp
===================================================================
--- lldb/trunk/unittests/Host/MainLoopTest.cpp
+++ lldb/trunk/unittests/Host/MainLoopTest.cpp
@@ -8,6 +8,8 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/MainLoop.h"
+#include "lldb/Host/ConnectionFileDescriptor.h"
+#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Host/common/TCPSocket.h"
#include "gtest/gtest.h"
#include <future>
@@ -107,6 +109,24 @@
}
#ifdef LLVM_ON_UNIX
+TEST_F(MainLoopTest, DetectsEOF) {
+ lldb_utility::PseudoTerminal term;
+ ASSERT_TRUE(term.OpenFirstAvailableMaster(O_RDWR, nullptr, 0));
+ ASSERT_TRUE(term.OpenSlave(O_RDWR | O_NOCTTY, nullptr, 0));
+ auto conn = llvm::make_unique<ConnectionFileDescriptor>(
+ term.ReleaseMasterFileDescriptor(), true);
+
+ Status error;
+ MainLoop loop;
+ auto handle =
+ loop.RegisterReadObject(conn->GetReadObject(), make_callback(), error);
+ ASSERT_TRUE(error.Success());
+ term.CloseSlaveFileDescriptor();
+
+ ASSERT_TRUE(loop.Run().Success());
+ ASSERT_EQ(1u, callback_count);
+}
+
TEST_F(MainLoopTest, Signal) {
MainLoop loop;
Status error;
Index: lldb/trunk/source/Host/common/MainLoop.cpp
===================================================================
--- lldb/trunk/source/Host/common/MainLoop.cpp
+++ lldb/trunk/source/Host/common/MainLoop.cpp
@@ -221,7 +221,7 @@
for (const auto &handle : fds) {
#else
for (const auto &fd : read_fds) {
- if ((fd.revents & POLLIN) == 0)
+ if ((fd.revents & (POLLIN | POLLHUP)) == 0)
continue;
IOObject::WaitableHandle handle = fd.fd;
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41008.126314.patch
Type: text/x-patch
Size: 1697 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171211/b0ee370a/attachment.bin>
More information about the lldb-commits
mailing list