From 6419c6e279816b21e30fef1a6ac4864df7fcf91d Mon Sep 17 00:00:00 2001
From: Brad Kittenbrink <brad@lindenlab.com>
Date: Thu, 18 Apr 2019 15:44:45 -0700
Subject: [PATCH] Removed unnecessary disconnection of listener in
 postAndSuspendSetup

---
 indra/llcommon/lleventcoro.cpp | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp
index 421897cb981..b1fb8ffd045 100644
--- a/indra/llcommon/lleventcoro.cpp
+++ b/indra/llcommon/lleventcoro.cpp
@@ -134,15 +134,12 @@ LLBoundListener postAndSuspendSetup(const std::string& callerName,
     // return the consuming attribute for some other coroutine, most likely
     // the main routine.
     bool consuming(LLCoros::get_consuming());
-
-    std::shared_ptr<LLBoundListener> connection_ptr = std::make_shared<LLBoundListener>();
-
     // make a callback that will assign a value to the future, and listen on
     // the specified LLEventPump with that callback
-    *connection_ptr = replyPump.getPump().listen(listenerName,
-                                   [&promise, consuming, listenerName, connection_ptr](const LLSD& result)
+    LLBoundListener connection(
+        replyPump.getPump().listen(listenerName,
+                                   [&promise, consuming, listenerName](const LLSD& result)
                                    {
-                                       connection_ptr->disconnect();
                                        try
                                        {
                                            promise.set_value(result);
@@ -153,7 +150,7 @@ LLBoundListener postAndSuspendSetup(const std::string& callerName,
                                                << listenerName << "' "  << ex.what() << LL_ENDL;
                                        }
                                        return consuming;
-                                   });
+                                   }));
     // skip the "post" part if requestPump is default-constructed
     if (requestPump)
     {
@@ -172,7 +169,7 @@ LLBoundListener postAndSuspendSetup(const std::string& callerName,
     LL_DEBUGS("lleventcoro") << callerName << ": coroutine " << listenerName
                              << " about to wait on LLEventPump " << replyPump.getPump().getName()
                              << LL_ENDL;
-    return *connection_ptr;
+    return connection;
 }
 
 } // anonymous
-- 
GitLab