Fix crash in LLTextureFetch::getWorker upon viewer exit.

This is now necessary since the curl thread no longer syncs with the
main thread: it is possible that a request finishes after a texture
fetch thread was shot down but before curl was stopped, and curl
calling BufferedCurlEasyRequest::processOutput while objects that the
responder uses were already destructed (most notably
LLTextureFetch itself).
This commit is contained in:
Aleric Inglewood
2013-03-21 20:26:01 +01:00
parent 00b223f2a4
commit 835240fda1
5 changed files with 46 additions and 9 deletions

View File

@@ -1992,20 +1992,33 @@ void BufferedCurlEasyRequest::processOutput(void)
{
print_diagnostics(code);
}
if (mBufferEventsTarget)
sResponderCallbackMutex.lock();
if (!sShuttingDown)
{
// Only the responder registers for these events.
llassert(mBufferEventsTarget == mResponder.get());
// Allow clients to parse result codes and headers before we attempt to parse
// the body and provide completed/result/error calls.
mBufferEventsTarget->completed_headers(responseCode, responseReason, (code == CURLE_FAILED_INIT) ? NULL : &info);
if (mBufferEventsTarget)
{
// Only the responder registers for these events.
llassert(mBufferEventsTarget == mResponder.get());
// Allow clients to parse result codes and headers before we attempt to parse
// the body and provide completed/result/error calls.
mBufferEventsTarget->completed_headers(responseCode, responseReason, (code == CURLE_FAILED_INIT) ? NULL : &info);
}
mResponder->finished(code, responseCode, responseReason, sChannels, mOutput);
}
mResponder->finished(code, responseCode, responseReason, sChannels, mOutput);
sResponderCallbackMutex.unlock();
mResponder = NULL;
resetState();
}
//static
void BufferedCurlEasyRequest::shutdown(void)
{
sResponderCallbackMutex.lock();
sShuttingDown = true;
sResponderCallbackMutex.unlock();
}
void BufferedCurlEasyRequest::received_HTTP_header(void)
{
if (mBufferEventsTarget)