summaryrefslogtreecommitdiff
path: root/indra/llcommon/llevents.cpp
diff options
context:
space:
mode:
authorbrad kittenbrink <brad@lindenlab.com>2009-08-27 16:25:02 -0400
committerbrad kittenbrink <brad@lindenlab.com>2009-08-27 16:25:02 -0400
commitd020dae7b9c156a08d1dd17eade7f36011f4d0fe (patch)
tree67b1a28222116b20c5fa7bcc1cbd86ca47a91aa7 /indra/llcommon/llevents.cpp
parent745845f79987e4b4ab7f5728746a0eda8898930f (diff)
parent70600ea66adc816e72e91e804deebde40ed6b1bc (diff)
Merged latest login-api with latest viewer-2.0.0-3 up through plugin-api-05 merge (r131929).
Some minor post-merge cleanups still required.
Diffstat (limited to 'indra/llcommon/llevents.cpp')
-rw-r--r--indra/llcommon/llevents.cpp44
1 files changed, 36 insertions, 8 deletions
diff --git a/indra/llcommon/llevents.cpp b/indra/llcommon/llevents.cpp
index eb380ba7c8..aec9acc7ef 100644
--- a/indra/llcommon/llevents.cpp
+++ b/indra/llcommon/llevents.cpp
@@ -38,6 +38,9 @@
#pragma warning (pop)
#endif
// other Linden headers
+#include "stringize.h"
+#include "llerror.h"
+#include "llsdutil.h"
/*****************************************************************************
* queue_names: specify LLEventPump names that should be instantiated as
@@ -56,14 +59,12 @@ const char* queue_names[] =
/*****************************************************************************
* If there's a "mainloop" pump, listen on that to flush all LLEventQueues
*****************************************************************************/
-struct RegisterFlush
+struct RegisterFlush : public LLEventTrackable
{
RegisterFlush():
- pumps(LLEventPumps::instance()),
- mainloop(pumps.obtain("mainloop")),
- name("flushLLEventQueues")
+ pumps(LLEventPumps::instance())
{
- mainloop.listen(name, boost::bind(&RegisterFlush::flush, this, _1));
+ pumps.obtain("mainloop").listen("flushLLEventQueues", boost::bind(&RegisterFlush::flush, this, _1));
}
bool flush(const LLSD&)
{
@@ -72,11 +73,9 @@ struct RegisterFlush
}
~RegisterFlush()
{
- mainloop.stopListening(name);
+ // LLEventTrackable handles stopListening for us.
}
LLEventPumps& pumps;
- LLEventPump& mainloop;
- const std::string name;
};
static RegisterFlush registerFlush;
@@ -256,6 +255,12 @@ LLEventPump::~LLEventPump()
// static data member
const LLEventPump::NameList LLEventPump::empty;
+std::string LLEventPump::inventName(const std::string& pfx)
+{
+ static long suffix = 0;
+ return STRINGIZE(pfx << suffix++);
+}
+
LLBoundListener LLEventPump::listen_impl(const std::string& name, const LLEventListener& listener,
const NameList& after,
const NameList& before)
@@ -499,3 +504,26 @@ bool LLListenerOrPumpName::operator()(const LLSD& event) const
}
return (*mListener)(event);
}
+
+void LLReqID::stamp(LLSD& response) const
+{
+ if (! (response.isUndefined() || response.isMap()))
+ {
+ // If 'response' was previously completely empty, it's okay to
+ // turn it into a map. If it was already a map, then it should be
+ // okay to add a key. But if it was anything else (e.g. a scalar),
+ // assigning a ["reqid"] key will DISCARD the previous value,
+ // replacing it with a map. That would be Bad.
+ LL_INFOS("LLReqID") << "stamp(" << mReqid << ") leaving non-map response unmodified: "
+ << response << LL_ENDL;
+ return;
+ }
+ LLSD oldReqid(response["reqid"]);
+ if (! (oldReqid.isUndefined() || llsd_equals(oldReqid, mReqid)))
+ {
+ LL_INFOS("LLReqID") << "stamp(" << mReqid << ") preserving existing [\"reqid\"] value "
+ << oldReqid << " in response: " << response << LL_ENDL;
+ return;
+ }
+ response["reqid"] = mReqid;
+}