Skip to content
Snippets Groups Projects
Unverified Commit db30ffc7 authored by akleshchev's avatar akleshchev Committed by GitHub
Browse files

SL-19690 Merge pull request #207 from RyeMutt/shutdown-crash

Fix exceptions during shutdown causing early program termination
parents 5ce70325 855cae27
No related branches found
No related tags found
2 merge requests!3Update to main branch,!2Rebase onto current main branch
...@@ -516,37 +516,45 @@ namespace LL ...@@ -516,37 +516,45 @@ namespace LL
// Here we believe target WorkQueue still exists. Post to it a // Here we believe target WorkQueue still exists. Post to it a
// lambda that packages our callable, our callback and a weak_ptr // lambda that packages our callable, our callback and a weak_ptr
// to this originating WorkQueue. // to this originating WorkQueue.
tptr->post( try
[reply = super::getWeak(), {
callable = std::move(callable), tptr->post(
callback = std::move(callback)] [reply = super::getWeak(),
() mutable callable = std::move(callable),
{ callback = std::move(callback)]
// Use postMaybe() below in case this originating WorkQueue () mutable
// has been closed or destroyed. Remember, the outer lambda is
// now running on a thread servicing the target WorkQueue, and
// real time has elapsed since postTo()'s tptr->post() call.
try
{
// Make a reply lambda to repost to THIS WorkQueue.
// Delegate to makeReplyLambda() so we can partially
// specialize on void return.
postMaybe(reply, makeReplyLambda(std::move(callable), std::move(callback)));
}
catch (...)
{ {
// Either variant of makeReplyLambda() is responsible for // Use postMaybe() below in case this originating WorkQueue
// calling the caller's callable. If that throws, return // has been closed or destroyed. Remember, the outer lambda is
// the exception to the originating thread. // now running on a thread servicing the target WorkQueue, and
postMaybe( // real time has elapsed since postTo()'s tptr->post() call.
reply, try
// Bind the current exception to transport back to the {
// originating WorkQueue. Once there, rethrow it. // Make a reply lambda to repost to THIS WorkQueue.
[exc = std::current_exception()](){ std::rethrow_exception(exc); }); // Delegate to makeReplyLambda() so we can partially
} // specialize on void return.
}, postMaybe(reply, makeReplyLambda(std::move(callable), std::move(callback)));
// if caller passed a TimePoint, pass it along to post() }
std::forward<ARGS>(args)...); catch (...)
{
// Either variant of makeReplyLambda() is responsible for
// calling the caller's callable. If that throws, return
// the exception to the originating thread.
postMaybe(
reply,
// Bind the current exception to transport back to the
// originating WorkQueue. Once there, rethrow it.
[exc = std::current_exception()](){ std::rethrow_exception(exc); });
}
},
// if caller passed a TimePoint, pass it along to post()
std::forward<ARGS>(args)...);
}
catch (const Closed&)
{
// target WorkQueue still exists, but is Closed
return false;
}
// looks like we were able to post() // looks like we were able to post()
return true; return true;
......
...@@ -92,14 +92,21 @@ LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage( ...@@ -92,14 +92,21 @@ LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(
{ {
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
// Instantiate the ImageRequest right in the lambda, why not? try
mThreadPool->getQueue().post( {
[req = ImageRequest(image, discard, needs_aux, responder)] // Instantiate the ImageRequest right in the lambda, why not?
() mutable mThreadPool->getQueue().post(
{ [req = ImageRequest(image, discard, needs_aux, responder)]
auto done = req.processRequest(); () mutable
req.finishRequest(done); {
}); auto done = req.processRequest();
req.finishRequest(done);
});
}
catch (const LLThreadSafeQueueInterrupt&)
{
LL_DEBUGS() << "Tried to start decoding on shutdown" << LL_ENDL;
}
// It's important to our consumer (LLTextureFetchWorker) that we return a // It's important to our consumer (LLTextureFetchWorker) that we return a
// nonzero handle. It is NOT important that the nonzero handle be unique: // nonzero handle. It is NOT important that the nonzero handle be unique:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment