From f664c2ea26fb63f162f3d988b6d00f1483be5d45 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 6 Feb 2024 14:49:45 -0500 Subject: Break out lua_function.h,.cpp and lualistener.h,.cpp. The intention is to decentralize Luau entry points into our C++ code, permitting a given entry point to be added to the .cpp file that already deals with that class or functional area. Continuing to add every such entry point to llluamanager.cpp doesn't scale well. Extract LuaListener class from llluamanager.cpp to its own header and .cpp file. Extract from llluamanager into lua_function.h (and .cpp) declarations useful for adding a lua_function Luau entry point, e.g.: lua_register() lua_rawlen() lua_tostdstring() lua_pushstdstring() lua_tollsd() lua_pushllsd() LuaPopper lua_function() and LuaFunction class LuaState lua_what lua_stack DebugExit --- indra/llcommon/lualistener.cpp | 103 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 indra/llcommon/lualistener.cpp (limited to 'indra/llcommon/lualistener.cpp') diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp new file mode 100644 index 0000000000..0fa03ffb3b --- /dev/null +++ b/indra/llcommon/lualistener.cpp @@ -0,0 +1,103 @@ +/** + * @file lualistener.cpp + * @author Nat Goodspeed + * @date 2024-02-06 + * @brief Implementation for lualistener. + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Copyright (c) 2024, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled header +#include "linden_common.h" +// associated header +#include "lualistener.h" +// STL headers +// std headers +#include // std::rand() +#include // std::memcpy() +// external library headers +#include "luau/lua.h" +// other Linden headers +#include "llerror.h" +#include "llleaplistener.h" +#include "lua_function.h" + +LuaListener::LuaListener(lua_State* L): + super(getUniqueKey()), + mListener( + new LLLeapListener( + [L](LLEventPump& pump, const std::string& listener) + { return connect(L, pump, listener); })) +{ + mReplyConnection = connect(L, mReplyPump, "LuaListener"); +} + +LuaListener::~LuaListener() +{ + LL_DEBUGS("Lua") << "~LuaListener('" << mReplyPump.getName() << "')" << LL_ENDL; +} + +int LuaListener::getUniqueKey() +{ + // Find a random key that does NOT already correspond to a LuaListener + // instance. Passing a duplicate key to LLInstanceTracker would do Bad + // Things. + int key; + do + { + key = std::rand(); + } while (LuaListener::getInstance(key)); + // This is theoretically racy, if we were instantiating new + // LuaListeners on multiple threads. Don't. + return key; +} + +LLBoundListener LuaListener::connect(lua_State* L, LLEventPump& pump, const std::string& listener) +{ + return pump.listen( + listener, + [L, pumpname=pump.getName()](const LLSD& data) + { return call_lua(L, pumpname, data); }); +} + +bool LuaListener::call_lua(lua_State* L, const std::string& pump, const LLSD& data) +{ + LL_INFOS("Lua") << "LuaListener::call_lua('" << pump << "', " << data << ")" << LL_ENDL; + if (! lua_checkstack(L, 3)) + { + LL_WARNS("Lua") << "Cannot extend Lua stack to call listen_events() callback" + << LL_ENDL; + return false; + } + // push the registered Lua callback function stored in our registry as + // "event.function" + lua_getfield(L, LUA_REGISTRYINDEX, "event.function"); + llassert(lua_isfunction(L, -1)); + // pass pump name + lua_pushstdstring(L, pump); + // then the data blob + lua_pushllsd(L, data); + // call the registered Lua listener function; allow it to return bool; + // no message handler + auto status = lua_pcall(L, 2, 1, 0); + bool result{ false }; + if (status != LUA_OK) + { + LL_WARNS("Lua") << "Error in listen_events() callback: " + << lua_tostdstring(L, -1) << LL_ENDL; + } + else + { + result = lua_toboolean(L, -1); + } + // discard either the error message or the bool return value + lua_pop(L, 1); + return result; +} + +std::string LuaListener::getCommandName() const +{ + return mListener->getPumpName(); +} -- cgit v1.2.3 From 85ef003ed7836cb351ee62ed44a4837a305e9dbd Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 22 Feb 2024 20:42:08 -0500 Subject: Lua listen_events(), await_event() => get_event_{pumps,next}(). Don't set up a Lua callback to receive incoming events, a la listen_events(). Don't listen on an arbitrary event pump, a la await_event(). Instead, the new get_event_pumps() entry point simply delivers the reply pump and command pump names (as listen_events() did) without storing a Lua callback. Make LuaListener capture incoming events on the reply pump in a queue. This avoids the problem of multiple events arriving too quickly for the Lua script to retrieve. If the queue gets too big, discard the excess instead of blocking the caller of post(). Then the new get_event_next() entry point retrieves the next (pump, data) pair from the queue, blocking the Lua script until a suitable event arrives. This is closer to the use of stdin for a LEAP plugin. It also addresses the question: what should the Lua script's C++ coroutine do while waiting for an incoming reply pump event? Recast llluamanager_test.cpp for this new, more straightforward API. Move LLLeap's and LuaListener's reply LLEventPump into LLLeapListener, which they both use. This simplifies LLLeapListener's API, which was a little convoluted: the caller supplied a connect callback to allow LLLeapListener to connect some listener to the caller's reply pump. Now, instead, the caller simply passes a bool(pumpname, data) callback to receive events incoming on LLLeapListener's own reply pump. Fix a latent bug in LLLeapListener: if a plugin called listen() more than once with the same listener name, the new connection would not have been saved. While at it, replace some older Boost features in LLLeapListener and LLLeap. --- indra/llcommon/lualistener.cpp | 76 ++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 44 deletions(-) (limited to 'indra/llcommon/lualistener.cpp') diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp index 0fa03ffb3b..ed34133924 100644 --- a/indra/llcommon/lualistener.cpp +++ b/indra/llcommon/lualistener.cpp @@ -24,20 +24,23 @@ #include "llleaplistener.h" #include "lua_function.h" -LuaListener::LuaListener(lua_State* L): - super(getUniqueKey()), - mListener( - new LLLeapListener( - [L](LLEventPump& pump, const std::string& listener) - { return connect(L, pump, listener); })) +const int MAX_QSIZE = 1000; + +std::ostream& operator<<(std::ostream& out, const LuaListener& self) { - mReplyConnection = connect(L, mReplyPump, "LuaListener"); + return out << "LuaListener(" << self.getReplyName() << ", " << self.getCommandName() << ")"; } +LuaListener::LuaListener(lua_State* L): + super(getUniqueKey()), + mListener(new LLLeapListener( + "LuaListener", + [this](const std::string& pump, const LLSD& data) + { return queueEvent(pump, data); })) +{} + LuaListener::~LuaListener() -{ - LL_DEBUGS("Lua") << "~LuaListener('" << mReplyPump.getName() << "')" << LL_ENDL; -} +{} int LuaListener::getUniqueKey() { @@ -54,50 +57,35 @@ int LuaListener::getUniqueKey() return key; } -LLBoundListener LuaListener::connect(lua_State* L, LLEventPump& pump, const std::string& listener) +std::string LuaListener::getReplyName() const { - return pump.listen( - listener, - [L, pumpname=pump.getName()](const LLSD& data) - { return call_lua(L, pumpname, data); }); + return mListener->getReplyPump().getName(); } -bool LuaListener::call_lua(lua_State* L, const std::string& pump, const LLSD& data) +std::string LuaListener::getCommandName() const { - LL_INFOS("Lua") << "LuaListener::call_lua('" << pump << "', " << data << ")" << LL_ENDL; - if (! lua_checkstack(L, 3)) - { - LL_WARNS("Lua") << "Cannot extend Lua stack to call listen_events() callback" - << LL_ENDL; - return false; - } - // push the registered Lua callback function stored in our registry as - // "event.function" - lua_getfield(L, LUA_REGISTRYINDEX, "event.function"); - llassert(lua_isfunction(L, -1)); - // pass pump name - lua_pushstdstring(L, pump); - // then the data blob - lua_pushllsd(L, data); - // call the registered Lua listener function; allow it to return bool; - // no message handler - auto status = lua_pcall(L, 2, 1, 0); - bool result{ false }; - if (status != LUA_OK) + return mListener->getPumpName(); +} + +bool LuaListener::queueEvent(const std::string& pump, const LLSD& data) +{ + // Our Lua script might be stalled, or just fail to retrieve events. Don't + // grow this queue indefinitely. But don't set MAX_QSIZE as the queue + // capacity or we'd block the post() call trying to propagate this event! + if (auto size = mQueue.size(); size > MAX_QSIZE) { - LL_WARNS("Lua") << "Error in listen_events() callback: " - << lua_tostdstring(L, -1) << LL_ENDL; + LL_WARNS("Lua") << "LuaListener queue for " << getReplyName() + << " exceeds " << MAX_QSIZE << ": " << size + << " -- discarding event" << LL_ENDL; } else { - result = lua_toboolean(L, -1); + mQueue.push(decltype(mQueue)::value_type(pump, data)); } - // discard either the error message or the bool return value - lua_pop(L, 1); - return result; + return false; } -std::string LuaListener::getCommandName() const +LuaListener::PumpData LuaListener::getNext() { - return mListener->getPumpName(); + return mQueue.pop(); } -- cgit v1.2.3 From ce73e5c5ab0c33673067d9322c98ae8800fa9224 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 28 Mar 2024 07:11:31 -0400 Subject: 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. --- indra/llcommon/lualistener.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/lualistener.cpp') diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp index ed34133924..37ce27a2a4 100644 --- a/indra/llcommon/lualistener.cpp +++ b/indra/llcommon/lualistener.cpp @@ -36,7 +36,24 @@ LuaListener::LuaListener(lua_State* L): mListener(new LLLeapListener( "LuaListener", [this](const std::string& pump, const LLSD& data) - { return queueEvent(pump, data); })) + { return queueEvent(pump, data); })), + // Listen for shutdown events on the "LLApp" LLEventPump. + mShutdownConnection( + LLEventPumps::instance().obtain("LLApp").listen( + LLEventPump::inventName("LuaState"), + [this](const LLSD& status) + { + LL_DEBUGS("LuaListener") << "caught " << status << LL_ENDL; + const auto& statsd = status["status"]; + if (statsd.asString() != "running") + { + // If a Lua script is still blocked in getNext() during + // viewer shutdown, close the queue to wake up getNext(). + LL_DEBUGS("LuaListener") << "closing queue" << LL_ENDL; + mQueue.close(); + } + return false; + })) {} LuaListener::~LuaListener() @@ -87,5 +104,15 @@ bool LuaListener::queueEvent(const std::string& pump, const LLSD& data) LuaListener::PumpData LuaListener::getNext() { - return mQueue.pop(); + try + { + return mQueue.pop(); + } + catch (const LLThreadSafeQueueInterrupt& exc) + { + // mQueue has been closed. The only way that happens is when we detect + // viewer shutdown. Terminate the calling coroutine. + LLCoros::checkStop(); + return {}; + } } -- cgit v1.2.3 From fc6f8197f5e8764d0c2c0234437a7003f1ce6a0d Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 28 Mar 2024 11:36:46 -0400 Subject: Eliminate unreferenced exception name --- indra/llcommon/lualistener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lualistener.cpp') diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp index 37ce27a2a4..ef9782824e 100644 --- a/indra/llcommon/lualistener.cpp +++ b/indra/llcommon/lualistener.cpp @@ -108,7 +108,7 @@ LuaListener::PumpData LuaListener::getNext() { return mQueue.pop(); } - catch (const LLThreadSafeQueueInterrupt& exc) + catch (const LLThreadSafeQueueInterrupt&) { // mQueue has been closed. The only way that happens is when we detect // viewer shutdown. Terminate the calling coroutine. -- cgit v1.2.3 From 15de45261585e8b2d89c5df9091639ecca1e20c4 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 28 Mar 2024 11:48:34 -0400 Subject: Ditch a couple LL_DEBUGS() messages. --- indra/llcommon/lualistener.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/llcommon/lualistener.cpp') diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp index ef9782824e..018a31d5a8 100644 --- a/indra/llcommon/lualistener.cpp +++ b/indra/llcommon/lualistener.cpp @@ -43,13 +43,11 @@ LuaListener::LuaListener(lua_State* L): LLEventPump::inventName("LuaState"), [this](const LLSD& status) { - LL_DEBUGS("LuaListener") << "caught " << status << LL_ENDL; const auto& statsd = status["status"]; if (statsd.asString() != "running") { // If a Lua script is still blocked in getNext() during // viewer shutdown, close the queue to wake up getNext(). - LL_DEBUGS("LuaListener") << "closing queue" << LL_ENDL; mQueue.close(); } return false; -- cgit v1.2.3 From b610b378ee3249b572d98875a0e557cbf80c2ded Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 2 Apr 2024 11:21:13 -0400 Subject: Use LLCoros::TempStatus when Lua is waiting on get_event_next(). When enumerating C++ coroutines, it can be useful to know that a particular Lua coroutine is simply waiting for further events. --- indra/llcommon/lualistener.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llcommon/lualistener.cpp') diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp index 018a31d5a8..82e32860db 100644 --- a/indra/llcommon/lualistener.cpp +++ b/indra/llcommon/lualistener.cpp @@ -104,6 +104,7 @@ LuaListener::PumpData LuaListener::getNext() { try { + LLCoros::TempStatus status("get_event_next()"); return mQueue.pop(); } catch (const LLThreadSafeQueueInterrupt&) -- cgit v1.2.3 From 799d1d595505acaa7f05a6d92db5f8f2d258f53e Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 8 Apr 2024 16:55:26 +0300 Subject: Add script termination option to 'Lua Scripts' floater --- indra/llcommon/lualistener.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/lualistener.cpp') diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp index 82e32860db..c11ab6b1c3 100644 --- a/indra/llcommon/lualistener.cpp +++ b/indra/llcommon/lualistener.cpp @@ -33,18 +33,20 @@ std::ostream& operator<<(std::ostream& out, const LuaListener& self) LuaListener::LuaListener(lua_State* L): super(getUniqueKey()), + mCoroName(LLCoros::getName()), mListener(new LLLeapListener( "LuaListener", [this](const std::string& pump, const LLSD& data) { return queueEvent(pump, data); })), // Listen for shutdown events on the "LLApp" LLEventPump. mShutdownConnection( - LLEventPumps::instance().obtain("LLApp").listen( + LLEventPumps::instance().obtain("LLLua").listen( LLEventPump::inventName("LuaState"), [this](const LLSD& status) { - const auto& statsd = status["status"]; - if (statsd.asString() != "running") + const auto& coro_name = status["coro"].asString(); + const auto& statsd = status["status"].asString(); + if ((statsd == "close_all") || ((statsd == "close") && (coro_name == mCoroName))) { // If a Lua script is still blocked in getNext() during // viewer shutdown, close the queue to wake up getNext(). -- cgit v1.2.3 From 396ae60e1528515d0cbdfc4290b24ccb172998c8 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 12 Apr 2024 19:28:29 +0300 Subject: 'Lua Scripts' floater clean up --- indra/llcommon/lualistener.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/lualistener.cpp') diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp index c11ab6b1c3..d4bd73a9fb 100644 --- a/indra/llcommon/lualistener.cpp +++ b/indra/llcommon/lualistener.cpp @@ -44,8 +44,8 @@ LuaListener::LuaListener(lua_State* L): LLEventPump::inventName("LuaState"), [this](const LLSD& status) { - const auto& coro_name = status["coro"].asString(); - const auto& statsd = status["status"].asString(); + auto coro_name = status["coro"].asString(); + auto statsd = status["status"].asString(); if ((statsd == "close_all") || ((statsd == "close") && (coro_name == mCoroName))) { // If a Lua script is still blocked in getNext() during -- cgit v1.2.3 From c78be38a6a4211f06876bc80b3f19f89a5f936e0 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 17 Apr 2024 16:39:37 -0400 Subject: Reintroduce LLCoros::killreq() to request killing a named coroutine. Make LLCoros constructor echo "LLApp" status-change events on new "LLCoros" event pump. Rename LLCoros::kill() to killreq() because this operation only registers a request for the named coroutine to terminate next time it calls checkStop(). Add a new CoroData member to record the name of the coroutine requesting termination. killreq() sets that and also posts "killreq" to "LLCoros". Add an optional final-cleanup callback to LLCoros::checkStop(). Make checkStop() check for a pending killreq() request as well as viewer termination. Introduce new LLCoros::Killed exception for that case. Introduce LLCoros::getStopListener(), with two overloads, to encapsulate some of the messy logic to listen (perhaps temporarily) for viewer shutdown. Both overloads are for use by code at the source end of a queue or promise or other resource for which coroutines might still be waiting at viewer shutdown time. One overload is specifically for when the caller knows the name of the one and only coroutine that will wait on the resource (e.g. because the caller IS that coroutine). That overload honors killreq(). Use getStopListener() to simplify the four existing places where we set up such a listener. Add a fifth: also make WorkQueue listen for viewer shutdown (resolving a TODO comment). Remove LLLUAmanager::terminateScript(), getTerminationList() and the static sTerminationList. In the Lua interrupt callback, instead of checking sTerminationList, call LLCoros::checkStop(). Change LLFloaterLUAScripts terminate-script logic to call LLCoros::killreq() instead of posting on "LLLua" and calling LLLUAmanager::terminateScript(). Drop LLApp::setStatus() posting to "LLLua" LLEventPump: the above makes that moot. --- indra/llcommon/lualistener.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'indra/llcommon/lualistener.cpp') diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp index d4bd73a9fb..b7036c1c48 100644 --- a/indra/llcommon/lualistener.cpp +++ b/indra/llcommon/lualistener.cpp @@ -38,21 +38,16 @@ LuaListener::LuaListener(lua_State* L): "LuaListener", [this](const std::string& pump, const LLSD& data) { return queueEvent(pump, data); })), - // Listen for shutdown events on the "LLApp" LLEventPump. + // Listen for shutdown events. mShutdownConnection( - LLEventPumps::instance().obtain("LLLua").listen( + LLCoros::getStopListener( LLEventPump::inventName("LuaState"), - [this](const LLSD& status) + mCoroName, + [this](const LLSD&) { - auto coro_name = status["coro"].asString(); - auto statsd = status["status"].asString(); - if ((statsd == "close_all") || ((statsd == "close") && (coro_name == mCoroName))) - { - // If a Lua script is still blocked in getNext() during - // viewer shutdown, close the queue to wake up getNext(). - mQueue.close(); - } - return false; + // If a Lua script is still blocked in getNext() during + // viewer shutdown, close the queue to wake up getNext(). + mQueue.close(); })) {} -- cgit v1.2.3 From c05bf5acd487e78e414e3d679f6ec5dbfaa4169d Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 18 Apr 2024 16:15:35 -0400 Subject: Remove redundant LLEventPump::inventName() call. --- indra/llcommon/lualistener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lualistener.cpp') diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp index b7036c1c48..5c4989e891 100644 --- a/indra/llcommon/lualistener.cpp +++ b/indra/llcommon/lualistener.cpp @@ -41,7 +41,7 @@ LuaListener::LuaListener(lua_State* L): // Listen for shutdown events. mShutdownConnection( LLCoros::getStopListener( - LLEventPump::inventName("LuaState"), + "LuaState", mCoroName, [this](const LLSD&) { -- cgit v1.2.3 From 5b6a5c757deaba3c2b361eb49f2e61630fe3eb47 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 17 Jun 2024 11:18:09 -0400 Subject: Store script's LuaListener in userdata in lua_State's Registry. Instead of deriving LuaListener from LLInstanceTracker with an int key, generating a unique int key and storing that key in the Registry, use new lua_emplace() to store the LuaListener directly in a Lua userdata object in the Lua Registry. Because lua_emplace() uses LL.atexit() to guarantee that ~LuaState will destroy the T object, we no longer need ~LuaState() to make a special call specifically to destroy the LuaListener, if any. So we no longer need LuaState::getListener() separate from obtainListener(). Since LuaListener is no longer an LLInstanceTracker subclass, make LuaState::obtainListener() return LuaListener& rather than LuaListener::ptr_t. --- indra/llcommon/lualistener.cpp | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'indra/llcommon/lualistener.cpp') diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp index 5c4989e891..6cb87e8af2 100644 --- a/indra/llcommon/lualistener.cpp +++ b/indra/llcommon/lualistener.cpp @@ -15,8 +15,7 @@ #include "lualistener.h" // STL headers // std headers -#include // std::rand() -#include // std::memcpy() +#include // std::quoted() // external library headers #include "luau/lua.h" // other Linden headers @@ -28,11 +27,11 @@ const int MAX_QSIZE = 1000; std::ostream& operator<<(std::ostream& out, const LuaListener& self) { - return out << "LuaListener(" << self.getReplyName() << ", " << self.getCommandName() << ")"; + return out << "LuaListener(" << std::quoted(self.mCoroName) << ", " + << self.getReplyName() << ", " << self.getCommandName() << ")"; } LuaListener::LuaListener(lua_State* L): - super(getUniqueKey()), mCoroName(LLCoros::getName()), mListener(new LLLeapListener( "LuaListener", @@ -49,24 +48,13 @@ LuaListener::LuaListener(lua_State* L): // viewer shutdown, close the queue to wake up getNext(). mQueue.close(); })) -{} +{ + LL_DEBUGS("Lua") << "LuaListener(" << std::quoted(mCoroName) << ")" << LL_ENDL; +} LuaListener::~LuaListener() -{} - -int LuaListener::getUniqueKey() { - // Find a random key that does NOT already correspond to a LuaListener - // instance. Passing a duplicate key to LLInstanceTracker would do Bad - // Things. - int key; - do - { - key = std::rand(); - } while (LuaListener::getInstance(key)); - // This is theoretically racy, if we were instantiating new - // LuaListeners on multiple threads. Don't. - return key; + LL_DEBUGS("Lua") << "~LuaListener(" << std::quoted(mCoroName) << ")" << LL_ENDL; } std::string LuaListener::getReplyName() const @@ -86,7 +74,7 @@ bool LuaListener::queueEvent(const std::string& pump, const LLSD& data) // capacity or we'd block the post() call trying to propagate this event! if (auto size = mQueue.size(); size > MAX_QSIZE) { - LL_WARNS("Lua") << "LuaListener queue for " << getReplyName() + LL_WARNS("Lua") << "LuaListener queue for " << mCoroName << " exceeds " << MAX_QSIZE << ": " << size << " -- discarding event" << LL_ENDL; } @@ -107,7 +95,7 @@ LuaListener::PumpData LuaListener::getNext() catch (const LLThreadSafeQueueInterrupt&) { // mQueue has been closed. The only way that happens is when we detect - // viewer shutdown. Terminate the calling coroutine. + // viewer shutdown. Terminate the calling Lua coroutine. LLCoros::checkStop(); return {}; } -- cgit v1.2.3 From 03d7f2b84daf9ab991de6cad7d6149abda1ef716 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 28 Aug 2024 21:16:56 -0400 Subject: Ditch trailing spaces. --- indra/llcommon/lualistener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lualistener.cpp') diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp index 6cb87e8af2..94085c6798 100644 --- a/indra/llcommon/lualistener.cpp +++ b/indra/llcommon/lualistener.cpp @@ -3,7 +3,7 @@ * @author Nat Goodspeed * @date 2024-02-06 * @brief Implementation for lualistener. - * + * * $LicenseInfo:firstyear=2024&license=viewerlgpl$ * Copyright (c) 2024, Linden Research, Inc. * $/LicenseInfo$ -- cgit v1.2.3