[llvm-branch-commits] [lldb] r354255 - Merging r354122:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Feb 18 02:31:47 PST 2019
Author: hans
Date: Mon Feb 18 02:31:46 2019
New Revision: 354255
URL: http://llvm.org/viewvc/llvm-project?rev=354255&view=rev
Log:
Merging r354122:
------------------------------------------------------------------------
r354122 | mgorny | 2019-02-15 13:13:02 +0100 (Fri, 15 Feb 2019) | 10 lines
[lldb] [MainLoop] Add kevent() EINTR handling
Add missing EINTR handling for kevent() calls. If the call is
interrupted, return from Poll() as if zero events were returned and let
the polling resume on next iteration. This fixes test flakiness
on NetBSD.
Includes a test case suggested by Pavel Labath on D42206.
Differential Revision: https://reviews.llvm.org/D58230
------------------------------------------------------------------------
Modified:
lldb/branches/release_80/ (props changed)
lldb/branches/release_80/source/Host/common/MainLoop.cpp
lldb/branches/release_80/unittests/Host/MainLoopTest.cpp
Propchange: lldb/branches/release_80/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb 18 02:31:46 2019
@@ -1,3 +1,3 @@
/lldb/branches/apple/python-GIL:156467-162159
/lldb/branches/iohandler:198360-200250
-/lldb/trunk:351327,351504,352116,352374,352382,353642,354029
+/lldb/trunk:351327,351504,352116,352374,352382,353642,354029,354122
Modified: lldb/branches/release_80/source/Host/common/MainLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_80/source/Host/common/MainLoop.cpp?rev=354255&r1=354254&r2=354255&view=diff
==============================================================================
--- lldb/branches/release_80/source/Host/common/MainLoop.cpp (original)
+++ lldb/branches/release_80/source/Host/common/MainLoop.cpp Mon Feb 18 02:31:46 2019
@@ -108,8 +108,14 @@ Status MainLoop::RunImpl::Poll() {
num_events = kevent(loop.m_kqueue, in_events.data(), in_events.size(),
out_events, llvm::array_lengthof(out_events), nullptr);
- if (num_events < 0)
- return Status(errno, eErrorTypePOSIX);
+ if (num_events < 0) {
+ if (errno == EINTR) {
+ // in case of EINTR, let the main loop run one iteration
+ // we need to zero num_events to avoid assertions failing
+ num_events = 0;
+ } else
+ return Status(errno, eErrorTypePOSIX);
+ }
return Status();
}
Modified: lldb/branches/release_80/unittests/Host/MainLoopTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_80/unittests/Host/MainLoopTest.cpp?rev=354255&r1=354254&r2=354255&view=diff
==============================================================================
--- lldb/branches/release_80/unittests/Host/MainLoopTest.cpp (original)
+++ lldb/branches/release_80/unittests/Host/MainLoopTest.cpp Mon Feb 18 02:31:46 2019
@@ -137,4 +137,28 @@ TEST_F(MainLoopTest, Signal) {
ASSERT_TRUE(loop.Run().Success());
ASSERT_EQ(1u, callback_count);
}
+
+// Test that a signal which is not monitored by the MainLoop does not
+// cause a premature exit.
+TEST_F(MainLoopTest, UnmonitoredSignal) {
+ MainLoop loop;
+ Status error;
+ struct sigaction sa;
+ sa.sa_sigaction = [](int, siginfo_t *, void *) { };
+ sa.sa_flags = SA_SIGINFO; // important: no SA_RESTART
+ sigemptyset(&sa.sa_mask);
+ ASSERT_EQ(0, sigaction(SIGUSR2, &sa, nullptr));
+
+ auto handle = loop.RegisterSignal(SIGUSR1, make_callback(), error);
+ ASSERT_TRUE(error.Success());
+ std::thread killer([]() {
+ sleep(1);
+ kill(getpid(), SIGUSR2);
+ sleep(1);
+ kill(getpid(), SIGUSR1);
+ });
+ ASSERT_TRUE(loop.Run().Success());
+ killer.join();
+ ASSERT_EQ(1u, callback_count);
+}
#endif
More information about the llvm-branch-commits
mailing list