summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llevents.h14
-rw-r--r--indra/llcommon/lua_function.cpp3
-rw-r--r--indra/llcommon/lua_function.h3
-rw-r--r--indra/llcommon/lualistener.cpp29
-rw-r--r--indra/llcommon/lualistener.h2
5 files changed, 32 insertions, 19 deletions
diff --git a/indra/llcommon/llevents.h b/indra/llcommon/llevents.h
index 77a405871d..c1b752a143 100644
--- a/indra/llcommon/llevents.h
+++ b/indra/llcommon/llevents.h
@@ -48,27 +48,13 @@
#pragma warning (pop)
#endif
-#include <boost/bind.hpp>
-#include <boost/utility.hpp> // noncopyable
#include <boost/optional/optional.hpp>
-#include <boost/visit_each.hpp>
-#include <boost/ref.hpp> // reference_wrapper
-#include <boost/type_traits/is_pointer.hpp>
-#include <boost/static_assert.hpp>
#include "llsd.h"
#include "llsingleton.h"
#include "lldependencies.h"
-#include "llstl.h"
#include "llexception.h"
#include "llhandle.h"
-/*==========================================================================*|
-// override this to allow binding free functions with more parameters
-#ifndef LLEVENTS_LISTENER_ARITY
-#define LLEVENTS_LISTENER_ARITY 10
-#endif
-|*==========================================================================*/
-
// hack for testing
#ifndef testable
#define testable private
diff --git a/indra/llcommon/lua_function.cpp b/indra/llcommon/lua_function.cpp
index 9f0abd5674..e731408c7d 100644
--- a/indra/llcommon/lua_function.cpp
+++ b/indra/llcommon/lua_function.cpp
@@ -31,6 +31,9 @@
#include "lualistener.h"
#include "stringize.h"
+#define lua_register(L, n, f) (lua_pushcfunction(L, (f), n), lua_setglobal(L, (n)))
+#define lua_rawlen lua_objlen
+
/*****************************************************************************
* luau namespace
*****************************************************************************/
diff --git a/indra/llcommon/lua_function.h b/indra/llcommon/lua_function.h
index 07848e38af..868c13c3f1 100644
--- a/indra/llcommon/lua_function.h
+++ b/indra/llcommon/lua_function.h
@@ -23,9 +23,6 @@
class LuaListener;
-#define lua_register(L, n, f) (lua_pushcfunction(L, (f), n), lua_setglobal(L, (n)))
-#define lua_rawlen lua_objlen
-
namespace lluau
{
// luau defines luaL_error() as void, but we want to use the Lua idiom of
diff --git a/indra/llcommon/lualistener.cpp b/indra/llcommon/lualistener.cpp
index ed34133924..018a31d5a8 100644
--- a/indra/llcommon/lualistener.cpp
+++ b/indra/llcommon/lualistener.cpp
@@ -36,7 +36,22 @@ 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)
+ {
+ 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().
+ mQueue.close();
+ }
+ return false;
+ }))
{}
LuaListener::~LuaListener()
@@ -87,5 +102,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&)
+ {
+ // mQueue has been closed. The only way that happens is when we detect
+ // viewer shutdown. Terminate the calling coroutine.
+ LLCoros::checkStop();
+ return {};
+ }
}
diff --git a/indra/llcommon/lualistener.h b/indra/llcommon/lualistener.h
index c13b7bbd5f..40ccfba8fe 100644
--- a/indra/llcommon/lualistener.h
+++ b/indra/llcommon/lualistener.h
@@ -12,6 +12,7 @@
#if ! defined(LL_LUALISTENER_H)
#define LL_LUALISTENER_H
+#include "llevents.h"
#include "llinstancetracker.h"
#include "llsd.h"
#include "llthreadsafequeue.h"
@@ -73,6 +74,7 @@ private:
LLThreadSafeQueue<PumpData> mQueue;
std::unique_ptr<LLLeapListener> mListener;
+ LLTempBoundListener mShutdownConnection;
};
#endif /* ! defined(LL_LUALISTENER_H) */