summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-03-28 07:11:31 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-03-28 07:11:31 -0400
commitce73e5c5ab0c33673067d9322c98ae8800fa9224 (patch)
tree5efe142b37454a04bedea3319e455ea4c6a2a8e5 /indra/newview
parent9fbfd3d0ad1ed2cb721129a59421f06fedd071bf (diff)
Terminate Lua scripts hanging in LL.get_event_next().
Make LuaListener listen for "LLApp" viewer shutdown events. On receiving such, it closes its queue. Then the C++ coroutine calling getNext() wakes up with an LLThreadSafeQueue exception, and calls LLCoros::checkStop() to throw one of the exceptions recognized by LLCoros::toplevel(). Add an llluamanager_test.cpp test to verify this behavior.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/tests/llluamanager_test.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/indra/newview/tests/llluamanager_test.cpp b/indra/newview/tests/llluamanager_test.cpp
index e10dedcf53..682289bd93 100644
--- a/indra/newview/tests/llluamanager_test.cpp
+++ b/indra/newview/tests/llluamanager_test.cpp
@@ -418,4 +418,25 @@ namespace tut
auto [count, result] = future.get();
ensure_equals("leap.lua: " + result.asString(), count, 0);
}
+
+ template<> template<>
+ void object::test<7>()
+ {
+ set_test_name("stop hanging Lua script");
+ const std::string lua(
+ "-- hanging Lua script should terminate\n"
+ "\n"
+ "LL.get_event_next()\n"
+ );
+ LuaState L;
+ auto future = LLLUAmanager::startScriptLine(L, lua);
+ // The problem with this test is that the LuaState is destroyed
+ // (disconnecting the listener) before the LLTestApp instance mApp is
+ // destroyed (sending the shutdown event). Explicitly simulate LLApp's
+ // event.
+ LLEventPumps::instance().obtain("LLApp").post(llsd::map("status", "quitting"));
+ // but now we have to give the startScriptLine() coroutine a chance to run
+ auto [count, result] = future.get();
+ ensure_equals(result.asString(), count, 0);
+ }
} // namespace tut