diff options
| author | Brad Kittenbrink <brad@lindenlab.com> | 2019-03-04 13:00:52 -0800 | 
|---|---|---|
| committer | Nat Goodspeed <nat@lindenlab.com> | 2020-03-25 18:39:21 -0400 | 
| commit | 66abe4ccab7b60e9056ee03b9536b9980599d5f0 (patch) | |
| tree | a22620e90200c3e9133eb90299c3d7a61f38dc5a | |
| parent | a26905b0c5570644bb7a65b952accfe2c3f81c33 (diff) | |
Attempt to close LLEventCoro's LLBoundListener connection when promise has been fulfilled.
| -rw-r--r-- | indra/llcommon/lleventcoro.cpp | 13 | ||||
| -rw-r--r-- | indra/llmessage/tests/llcoproceduremanager_test.cpp | 2 | 
2 files changed, 9 insertions, 6 deletions
| diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index 367ddf485d..aa9f4b7840 100644 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -134,12 +134,15 @@ 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 -    LLBoundListener connection( -        replyPump.getPump().listen(listenerName, -                                   [&promise, consuming, listenerName](const LLSD& result) +    *connection_ptr = replyPump.getPump().listen(listenerName, +                                   [&promise, consuming, listenerName, connection_ptr](const LLSD& result)                                     { +                                       connection_ptr->disconnect();                                         try                                         {                                             promise.set_value(result); @@ -150,7 +153,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)      { @@ -169,7 +172,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; +    return *connection_ptr;  }  } // anonymous diff --git a/indra/llmessage/tests/llcoproceduremanager_test.cpp b/indra/llmessage/tests/llcoproceduremanager_test.cpp index 8c4937fd84..8ba9a84356 100644 --- a/indra/llmessage/tests/llcoproceduremanager_test.cpp +++ b/indra/llmessage/tests/llcoproceduremanager_test.cpp @@ -4,7 +4,7 @@   * @date 2019-02   * @brief LLCoprocedureManager unit test   * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $LicenseInfo:firstyear=2019&license=viewerlgpl$   * Second Life Viewer Source Code   * Copyright (C) 2010, Linden Research, Inc.   *  | 
