diff options
Diffstat (limited to 'indra/newview/llviewermedia.cpp')
-rwxr-xr-x | indra/newview/llviewermedia.cpp | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index f332a4e98e..4e8fa28b86 100755 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1280,7 +1280,7 @@ void LLViewerMedia::getOpenIDCookieCoro(std::string url) LL_DEBUGS("MediaAuth") << "Requesting " << url << LL_ENDL; LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << sOpenIDCookie << "]" << LL_ENDL; - LLSD result = httpAdapter->getRawAndYield(httpRequest, url, httpOpts, httpHeaders); + LLSD result = httpAdapter->getRawAndSuspend(httpRequest, url, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1347,7 +1347,7 @@ void LLViewerMedia::openIDSetupCoro(std::string openidUrl, std::string openidTok bas << std::noskipws << openidToken; - LLSD result = httpAdapter->postRawAndYield(httpRequest, openidUrl, rawbody, httpOpts, httpHeaders); + LLSD result = httpAdapter->postRawAndSuspend(httpRequest, openidUrl, rawbody, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -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); @@ -2600,7 +2603,7 @@ void LLViewerMediaImpl::mimeDiscoveryCoro(std::string url) httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); httpHeaders->append(HTTP_OUT_HEADER_COOKIE, ""); - LLSD result = httpAdapter->getRawAndYield(httpRequest, url, httpOpts, httpHeaders); + LLSD result = httpAdapter->getRawAndSuspend(httpRequest, url, httpOpts, httpHeaders); mMimeProbe.reset(); @@ -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(); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -3634,7 +3649,7 @@ void LLViewerMediaImpl::cancelMimeTypeProbe() LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t probeAdapter = mMimeProbe.lock(); if (probeAdapter) - probeAdapter->cancelYieldingOperation(); + probeAdapter->cancelSuspendedOperation(); } void LLViewerMediaImpl::addObject(LLVOVolume* obj) |