From 4f99e217d3c76c8651a3bfc2528fe5b68c62d34c Mon Sep 17 00:00:00 2001 From: Nicky Date: Tue, 24 May 2016 18:50:42 +0200 Subject: [PATCH] Remove temporary HttpRequestPumper eventnames from mainloop eventpump --- indra/llcommon/lldependencies.h | 3 +++ indra/llcommon/llevents.cpp | 8 ++++++++ indra/llcommon/llevents.h | 2 ++ indra/llmessage/llcorehttputil.cpp | 7 ++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/indra/llcommon/lldependencies.h b/indra/llcommon/lldependencies.h index e0294e271b..9e9e4e4dec 100644 --- a/indra/llcommon/lldependencies.h +++ b/indra/llcommon/lldependencies.h @@ -721,6 +721,9 @@ public: template dep_range get_before_range(const KEY_OR_ITER& key) const; + void clearCache() + { mCache.clear(); } + private: DepNodeMap mNodes; mutable iterator_list mCache; diff --git a/indra/llcommon/llevents.cpp b/indra/llcommon/llevents.cpp index 645c29d770..d9b0112edb 100644 --- a/indra/llcommon/llevents.cpp +++ b/indra/llcommon/llevents.cpp @@ -480,6 +480,14 @@ void LLEventPump::stopListening(const std::string& name) // avoid a new dependency sort in such cases. } +// Allow full unregister, or mDeps will grow and grow with stale entries from temporary HttpRequestPumper instances +void LLEventPump::removeFromDeps( std::string const &a_strName ) +{ + mDeps.remove( a_strName ); + mDeps.clearCache(); +} +// getListener(name).disconnect() because stopListening() also /// forgets this name. virtual void stopListening(const std::string& name); + void removeFromDeps( std::string const &a_strName ); // Allow full unregister, or mDeps will grow and grow with stale entries from temporary HttpRequestPumper instances + /// Post an event to all listeners. The @c bool return is only meaningful /// if the underlying leaf class is LLEventStream -- beware of relying on /// it too much! Truthfully, we return @c bool mostly to permit chaining diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 229bc9b3db..6e527cc62a 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -102,6 +102,7 @@ private: LLTempBoundListener mBoundListener; LLCore::HttpRequest::ptr_t mHttpRequest; + std::string mEventName; // Remember event name for unregister }; @@ -641,8 +642,9 @@ LLSD HttpCoroJSONHandler::parseBody(LLCore::HttpResponse *response, bool &succes HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request) : mHttpRequest(request) { + mEventName = LLEventPump::inventName(); // Remember name for unregister mBoundListener = LLEventPumps::instance().obtain("mainloop"). - listen(LLEventPump::inventName(), boost::bind(&HttpRequestPumper::pollRequest, this, _1)); + listen( mEventName, boost::bind(&HttpRequestPumper::pollRequest, this, _1)); } HttpRequestPumper::~HttpRequestPumper() @@ -651,6 +653,9 @@ HttpRequestPumper::~HttpRequestPumper() { mBoundListener.disconnect(); } + + LLEventPumps::instance().obtain( "mainloop" ).removeFromDeps( mEventName ); // Unregister, or mDeps of mainloop pump will grow and grow with stale entries from temporary HttpRequestPumper instances + } bool HttpRequestPumper::pollRequest(const LLSD&)