diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2019-10-16 08:52:51 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2020-03-25 18:52:11 -0400 |
commit | 6945755e5299e071e46d53f09821ac73993f7afe (patch) | |
tree | 64c55b8ae3118ace7b7d1edd385879c8a37b77b1 /indra/llcommon/lleventcoro.cpp | |
parent | afaad3cef749e926cb63b6aed0c14f25d3495d55 (diff) |
DRTVWR-476: Validate LLEventPumpOrPumpName replyPump
passed to postAndSuspendsetup().
The requestPump is optional, and the function varies its behavior depending on
whether that parameter is empty or meaningful. But it unconditionally uses the
replyPump. Passing an empty LLEventPumpOrPumpName caused mysterious crashes.
Add llassert_always_msg() to make the coding error explicit in such a case.
Also streamline access to meaningful requestPump and replyPump by temporarily
caching the bound LLEventPump reference.
Diffstat (limited to 'indra/llcommon/lleventcoro.cpp')
-rw-r--r-- | indra/llcommon/lleventcoro.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index 18a3595c24..bc7f947be1 100644 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -125,8 +125,8 @@ LLBoundListener postAndSuspendSetup(const std::string& callerName, const std::string& listenerName, LLCoros::Promise<LLSD>& promise, const LLSD& event, - const LLEventPumpOrPumpName& requestPump, - const LLEventPumpOrPumpName& replyPump, + const LLEventPumpOrPumpName& requestPumpP, + const LLEventPumpOrPumpName& replyPumpP, const LLSD& replyPumpNamePath) { // Get the consuming attribute for THIS coroutine, the one that's about to @@ -134,10 +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()); - // make a callback that will assign a value to the future, and listen on - // the specified LLEventPump with that callback + // listen on the specified LLEventPump with a lambda that will assign a + // value to the promise, thus fulfilling its future + llassert_always_msg(replyPumpP, ("replyPump required for " + callerName)); + LLEventPump& replyPump{replyPumpP.getPump()}; LLBoundListener connection( - replyPump.getPump().listen( + replyPump.listen( listenerName, [&promise, consuming, listenerName](const LLSD& result) { @@ -151,30 +153,31 @@ LLBoundListener postAndSuspendSetup(const std::string& callerName, } catch(boost::fibers::promise_already_satisfied & ex) { - LL_WARNS("lleventcoro") << "promise already satisfied in '" - << listenerName << "' " << ex.what() << LL_ENDL; + LL_DEBUGS("lleventcoro") << "promise already satisfied in '" + << listenerName << "': " << ex.what() << LL_ENDL; // We could not propagate the result value to the // listener. return false; } })); // skip the "post" part if requestPump is default-constructed - if (requestPump) + if (requestPumpP) { + LLEventPump& requestPump{requestPumpP.getPump()}; // If replyPumpNamePath is non-empty, store the replyPump name in the // request event. LLSD modevent(event); - storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); + storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getName()); LL_DEBUGS("lleventcoro") << callerName << ": coroutine " << listenerName - << " posting to " << requestPump.getPump().getName() + << " posting to " << requestPump.getName() << LL_ENDL; // *NOTE:Mani - Removed because modevent could contain user's hashed passwd. // << ": " << modevent << LL_ENDL; - requestPump.getPump().post(modevent); + requestPump.post(modevent); } LL_DEBUGS("lleventcoro") << callerName << ": coroutine " << listenerName - << " about to wait on LLEventPump " << replyPump.getPump().getName() + << " about to wait on LLEventPump " << replyPump.getName() << LL_ENDL; return connection; } |