summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermedia.cpp
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2015-10-21 14:29:58 -0700
committerRider Linden <rider@lindenlab.com>2015-10-21 14:29:58 -0700
commitf003455786c8cad0eefd7b896bb3359bcba301bd (patch)
tree193c542c75c12f39a723e59e47b28767f766d147 /indra/newview/llviewermedia.cpp
parent825106f0ee6de275b18afbd1fd1691bb8f5be036 (diff)
MAINT-5780: Be sure that the LLViewerMediaImpl instance does not get deleted while the MIME discovery coroutine is executing. If the refcount on the instance is 1 perform no processing.
Diffstat (limited to 'indra/newview/llviewermedia.cpp')
-rwxr-xr-xindra/newview/llviewermedia.cpp57
1 files changed, 36 insertions, 21 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 75a201d92f..4e8fa28b86 100755
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -2592,6 +2592,9 @@ void LLViewerMediaImpl::mimeDiscoveryCoro(std::string url)
LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
+ // Increment our refcount so that we do not go away while the coroutine is active.
+ this->ref();
+
mMimeProbe = httpAdapter;
httpOpts->setFollowRedirects(true);
@@ -2612,35 +2615,47 @@ void LLViewerMediaImpl::mimeDiscoveryCoro(std::string url)
LL_WARNS() << "Error retrieving media headers." << LL_ENDL;
}
- LLSD resultHeaders = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS];
-
- const std::string& mediaType = resultHeaders[HTTP_IN_HEADER_CONTENT_TYPE].asStringRef();
+ if (this->getNumRefs() > 1)
+ { // if there is only a single ref count outstanding it will be the one we took out above...
+ // we can skip the rest of this routine
- std::string::size_type idx1 = mediaType.find_first_of(";");
- std::string mimeType = mediaType.substr(0, idx1);
+ LLSD resultHeaders = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS];
- // We now no longer need to check the error code returned from the probe.
- // If we have a mime type, use it. If not, default to the web plugin and let it handle error reporting.
- // The probe was successful.
- if (mimeType.empty())
- {
- // Some sites don't return any content-type header at all.
- // Treat an empty mime type as text/html.
- mimeType = HTTP_CONTENT_TEXT_HTML;
- }
+ const std::string& mediaType = resultHeaders[HTTP_IN_HEADER_CONTENT_TYPE].asStringRef();
- LL_DEBUGS() << "Media type \"" << mediaType << "\", mime type is \"" << mimeType << "\"" << LL_ENDL;
+ std::string::size_type idx1 = mediaType.find_first_of(";");
+ std::string mimeType = mediaType.substr(0, idx1);
- // the call to initializeMedia may disconnect the responder, which will clear mMediaImpl.
- // Make a local copy so we can call loadURI() afterwards.
+ // We now no longer need to check the error code returned from the probe.
+ // If we have a mime type, use it. If not, default to the web plugin and let it handle error reporting.
+ // The probe was successful.
+ if (mimeType.empty())
+ {
+ // Some sites don't return any content-type header at all.
+ // Treat an empty mime type as text/html.
+ mimeType = HTTP_CONTENT_TEXT_HTML;
+ }
- if (!mimeType.empty())
- {
- if (initializeMedia(mimeType))
+ LL_DEBUGS() << "Media type \"" << mediaType << "\", mime type is \"" << mimeType << "\"" << LL_ENDL;
+
+ // the call to initializeMedia may disconnect the responder, which will clear mMediaImpl.
+ // Make a local copy so we can call loadURI() afterwards.
+
+ if (!mimeType.empty())
{
- loadURI();
+ if (initializeMedia(mimeType))
+ {
+ loadURI();
+ }
}
+
}
+ else
+ {
+ LL_WARNS() << "LLViewerMediaImpl to be released." << LL_ENDL;
+ }
+
+ this->unref();
}
//////////////////////////////////////////////////////////////////////////////////////////