Skip to content
Snippets Groups Projects
Commit 83543e55 authored by Rider Linden's avatar Rider Linden
Browse files

Memory leak (extra ref) in webprofile

Viewer media routines to coroutine.
Post with raw respons in llcorehttputil
LLCore::Http added headers only option (applies only on get)
parent 9134a3a0
No related branches found
No related tags found
No related merge requests found
......@@ -532,6 +532,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
long sslPeerV(0L);
long sslHostV(0L);
long dnsCacheTimeout(-1L);
long nobody(0L);
if (mReqOptions)
{
......@@ -539,6 +540,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
sslPeerV = mReqOptions->getSSLVerifyPeer() ? 1L : 0L;
sslHostV = mReqOptions->getSSLVerifyHost() ? 2L : 0L;
dnsCacheTimeout = mReqOptions->getDNSCacheTimeout();
nobody = mReqOptions->getHeadersOnly() ? 1L : 0L;
}
code = curl_easy_setopt(mCurlHandle, CURLOPT_FOLLOWLOCATION, follow_redirect);
check_curl_easy_code(code, CURLOPT_FOLLOWLOCATION);
......@@ -548,6 +550,9 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
code = curl_easy_setopt(mCurlHandle, CURLOPT_SSL_VERIFYHOST, sslHostV);
check_curl_easy_code(code, CURLOPT_SSL_VERIFYHOST);
code = curl_easy_setopt(mCurlHandle, CURLOPT_NOBODY, nobody);
check_curl_easy_code(code, CURLOPT_NOBODY);
// The Linksys WRT54G V5 router has an issue with frequent
// DNS lookups from LAN machines. If they happen too often,
// like for every HTTP request, the router gets annoyed after
......@@ -587,7 +592,8 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
switch (mReqMethod)
{
case HOR_GET:
code = curl_easy_setopt(mCurlHandle, CURLOPT_HTTPGET, 1);
if (nobody == 0)
code = curl_easy_setopt(mCurlHandle, CURLOPT_HTTPGET, 1);
check_curl_easy_code(code, CURLOPT_HTTPGET);
break;
......
......@@ -34,16 +34,17 @@ namespace LLCore
HttpOptions::HttpOptions() : RefCounted(true),
mWantHeaders(false),
mTracing(HTTP_TRACE_OFF),
mTimeout(HTTP_REQUEST_TIMEOUT_DEFAULT),
mTransferTimeout(HTTP_REQUEST_XFER_TIMEOUT_DEFAULT),
mRetries(HTTP_RETRY_COUNT_DEFAULT),
mUseRetryAfter(HTTP_USE_RETRY_AFTER_DEFAULT),
mFollowRedirects(false),
mVerifyPeer(false),
mVerifyHost(false),
mDNSCacheTimeout(-1L)
mWantHeaders(false),
mTracing(HTTP_TRACE_OFF),
mTimeout(HTTP_REQUEST_TIMEOUT_DEFAULT),
mTransferTimeout(HTTP_REQUEST_XFER_TIMEOUT_DEFAULT),
mRetries(HTTP_RETRY_COUNT_DEFAULT),
mUseRetryAfter(HTTP_USE_RETRY_AFTER_DEFAULT),
mFollowRedirects(false),
mVerifyPeer(false),
mVerifyHost(false),
mDNSCacheTimeout(-1L),
mNoBody(false)
{}
......@@ -104,4 +105,12 @@ void HttpOptions::setDNSCacheTimeout(int timeout)
{
mDNSCacheTimeout = timeout;
}
void HttpOptions::setHeadersOnly(bool nobody)
{
mNoBody = nobody;
if (mNoBody)
setWantHeaders(true);
}
} // end namespace LLCore
......@@ -149,6 +149,15 @@ class HttpOptions : public LLCoreInt::RefCounted
{
return mDNSCacheTimeout;
}
/// Retrieve only the headers and status from the request. Setting this
/// to true implies setWantHeaders(true) as well.
/// Default: false
void setHeadersOnly(bool nobody);
bool getHeadersOnly() const
{
return mNoBody;
}
protected:
bool mWantHeaders;
......@@ -161,6 +170,7 @@ class HttpOptions : public LLCoreInt::RefCounted
bool mVerifyPeer;
bool mVerifyHost;
int mDNSCacheTimeout;
bool mNoBody;
}; // end class HttpOptions
......
......@@ -256,7 +256,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons
buildStatusEntry(response, status, result);
#if 0
#if 1
// commenting out, but keeping since this can be useful for debugging
if (!status)
{
......@@ -608,6 +608,16 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques
return postAndYield_(self, request, url, rawbody, options, headers, httpHandler);
}
LLSD HttpCoroutineAdapter::postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request,
const std::string & url, LLCore::BufferArray::ptr_t rawbody,
LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName, true);
HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroRawHandler(replyPump));
return postAndYield_(self, request, url, rawbody, options, headers, httpHandler);
}
LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request,
const std::string & url, LLCore::BufferArray::ptr_t &rawbody,
LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,
......
......@@ -334,6 +334,19 @@ class HttpCoroutineAdapter
LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers);
}
LLSD postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request,
const std::string & url, LLCore::BufferArray::ptr_t rawbody,
LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false),
LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false));
LLSD postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request,
const std::string & url, LLCore::BufferArray::ptr_t &rawbody,
LLCore::HttpHeaders::ptr_t &headers)
{
return postRawAndYield(self, request, url, rawbody,
LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false), headers);
}
/// Execute a Put transaction on the supplied URL and yield execution of
/// the coroutine until a result is available.
///
......
This diff is collapsed.
......@@ -40,6 +40,9 @@
#include "llnotificationptr.h"
#include "llurl.h"
#include "lleventcoro.h"
#include "llcoros.h"
#include "llcorehttputil.h"
class LLViewerMediaImpl;
class LLUUID;
......@@ -165,7 +168,10 @@ class LLViewerMedia
private:
static void setOpenIDCookie();
static void onTeleportFinished();
static void openIDSetupCoro(LLCoros::self& self, std::string openidUrl, std::string openidToken);
static void getOpenIDCookieCoro(LLCoros::self& self, std::string url);
static LLPluginCookieStore *sCookieStore;
static LLURL sOpenIDURL;
static std::string sOpenIDCookie;
......@@ -180,7 +186,6 @@ class LLViewerMediaImpl
public:
friend class LLViewerMedia;
friend class LLMimeDiscoveryResponder;
LLViewerMediaImpl(
const LLUUID& texture_id,
......@@ -453,7 +458,6 @@ class LLViewerMediaImpl
S32 mProximity;
F64 mProximityDistance;
F64 mProximityCamera;
LLMimeDiscoveryResponder *mMimeTypeProbe;
bool mMediaAutoPlay;
std::string mMediaEntryURL;
bool mInNearbyMediaList; // used by LLPanelNearbyMedia::refreshList() for performance reasons
......@@ -470,6 +474,10 @@ class LLViewerMediaImpl
BOOL mIsUpdated ;
std::list< LLVOVolume* > mObjectList ;
void mimeDiscoveryCoro(LLCoros::self& self, std::string url);
LLCoreHttpUtil::HttpCoroutineAdapter::wptr_t mMimeProbe;
bool mCanceling;
private:
LLViewerMediaTexture *updatePlaceholderImage();
};
......
......@@ -202,7 +202,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointer<LLImageFormatt
/*static*/
LLCore::BufferArray::ptr_t LLWebProfile::buildPostData(const LLSD &data, LLPointer<LLImageFormatted> &image, const std::string &boundary)
{
LLCore::BufferArray::ptr_t body(new LLCore::BufferArray);
LLCore::BufferArray::ptr_t body(new LLCore::BufferArray, false);
LLCore::BufferArrayStream bas(body.get());
// *NOTE: The order seems to matter.
......
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