diff options
41 files changed, 931 insertions, 1272 deletions
| diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp index d76401d01b..6cca5e7c60 100755 --- a/indra/llcommon/llcoros.cpp +++ b/indra/llcommon/llcoros.cpp @@ -61,7 +61,7 @@ LLCoros::coro::self& LLCoros::get_self()      return *current->mSelf;  } -llcoro::Suspending::Suspending(): +LLCoros::Suspending::Suspending():      mSuspended(LLCoros::sCurrentCoro.get())  {      // Revert mCurrentCoro to the value it had at the moment we last switched @@ -69,7 +69,7 @@ llcoro::Suspending::Suspending():      LLCoros::sCurrentCoro.reset(mSuspended->mPrev);  } -llcoro::Suspending::~Suspending() +LLCoros::Suspending::~Suspending()  {      // Okay, we're back, update our mPrev      mSuspended->mPrev = LLCoros::sCurrentCoro.get(); diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 56eed8cafe..05bd87dc3c 100755 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -144,6 +144,18 @@ public:       */      std::string getName() const; +    /// get the current coro::self& for those who really really care +    static coro::self& get_self(); + +    /// Instantiate one of these in a block surrounding any leaf point when +    /// control literally switches away from this coroutine. +    class Suspending +    public: +        Suspending(); +        ~Suspending(); +    private: +        coro::self* mSuspended; +    };      /// for delayed initialization      void setStackSize(S32 stacksize); diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index 85af0d9b9f..a37b87f085 100755 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -41,7 +41,7 @@  #include "llerror.h"  #include "llcoros.h" -namespace +std::string LLEventDetail::listenerNameForCoro()  {  /** @@ -143,24 +143,14 @@ void storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value)      *pdest = value;  } -} // anonymous - -void llcoro::yield() -{ -    // By viewer convention, we post an event on the "mainloop" LLEventPump -    // each iteration of the main event-handling loop. So waiting for a single -    // event on "mainloop" gives us a one-frame yield. -    waitForEventOn("mainloop"); -} - -LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, -                         const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) +LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, +                 const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath)  {      // declare the future      boost::dcoroutines::future<LLSD> future(LLCoros::get_self());      // make a callback that will assign a value to the future, and listen on      // the specified LLEventPump with that callback -    std::string listenerName(listenerNameForCoro()); +    std::string listenerName(LLEventDetail::listenerNameForCoro());      LLTempBoundListener connection(          replyPump.getPump().listen(listenerName,                                     voidlistener(boost::dcoroutines::make_callback(future)))); @@ -170,7 +160,7 @@ LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& request          // If replyPumpNamePath is non-empty, store the replyPump name in the          // request event.          LLSD modevent(event); -        storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); +        LLEventDetail::storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName());          LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName                                   << " posting to " << requestPump.getPump().getName()                                   << LL_ENDL; @@ -186,7 +176,7 @@ LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& request      LLSD value;      {          // instantiate Suspending to manage the "current" coroutine -        llcoro::Suspending suspended; +        LLCoros::Suspending suspended;          value = *future;      } // destroy Suspending as soon as we're back      LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName @@ -195,6 +185,72 @@ LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& request      return value;  } +LLEventWithID postAndWait2(const LLSD& event, +                           const LLEventPumpOrPumpName& requestPump, +                           const LLEventPumpOrPumpName& replyPump0, +                           const LLEventPumpOrPumpName& replyPump1, +                           const LLSD& replyPump0NamePath, +                           const LLSD& replyPump1NamePath) +{ +    // declare the future +    boost::dcoroutines::future<LLEventWithID> future(LLCoros::get_self()); +    // either callback will assign a value to this future; listen on +    // each specified LLEventPump with a callback +    std::string name(LLEventDetail::listenerNameForCoro()); +    LLTempBoundListener connection0( +        replyPump0.getPump().listen(name + "a", +                               LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 0))); +    LLTempBoundListener connection1( +        replyPump1.getPump().listen(name + "b", +                               LLEventDetail::wfeoh(boost::dcoroutines::make_callback(future), 1))); +    // skip the "post" part if requestPump is default-constructed +    if (requestPump) +    { +        // If either replyPumpNamePath is non-empty, store the corresponding +        // replyPump name in the request event. +        LLSD modevent(event); +        LLEventDetail::storeToLLSDPath(modevent, replyPump0NamePath, +                                       replyPump0.getPump().getName()); +        LLEventDetail::storeToLLSDPath(modevent, replyPump1NamePath, +                                       replyPump1.getPump().getName()); +        LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name +                                 << " posting to " << requestPump.getPump().getName() +                                 << ": " << modevent << LL_ENDL; +        requestPump.getPump().post(modevent); +    } +    LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name +                             << " about to wait on LLEventPumps " << replyPump0.getPump().getName() +                             << ", " << replyPump1.getPump().getName() << LL_ENDL; +    // trying to dereference ("resolve") the future makes us wait for it +    LLEventWithID value; +    { +        // instantiate Suspending to manage "current" coroutine +        LLCoros::Suspending suspended; +        value = *future; +    } // destroy Suspending as soon as we're back +    LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name +                             << " resuming with (" << value.first << ", " << value.second << ")" +                             << LL_ENDL; +    // returning should disconnect both connections +    return value; +} + +} // anonymous + +void llcoro::yield() +{ +    // By viewer convention, we post an event on the "mainloop" LLEventPump +    // each iteration of the main event-handling loop. So waiting for a single +    // event on "mainloop" gives us a one-frame yield. +    waitForEventOn("mainloop"); +} + +LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, +                         const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) +    boost::dcoroutines::future<LLSD> future(llcoro::get_self()); +    std::string listenerName(listenerNameForCoro()); +        storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); +        llcoro::Suspending suspended;  namespace  { @@ -242,56 +298,15 @@ WaitForEventOnHelper<LISTENER> wfeoh(const LISTENER& listener, int discriminator  namespace llcoro  { -LLEventWithID postAndWait2(const LLSD& event, -                           const LLEventPumpOrPumpName& requestPump, -                           const LLEventPumpOrPumpName& replyPump0, -                           const LLEventPumpOrPumpName& replyPump1, -                           const LLSD& replyPump0NamePath, -                           const LLSD& replyPump1NamePath) -{ -    // declare the future      boost::dcoroutines::future<LLEventWithID> future(LLCoros::get_self()); -    // either callback will assign a value to this future; listen on -    // each specified LLEventPump with a callback      std::string name(listenerNameForCoro()); -    LLTempBoundListener connection0( -        replyPump0.getPump().listen(name + "a",                                      wfeoh(boost::dcoroutines::make_callback(future), 0))); -    LLTempBoundListener connection1( -        replyPump1.getPump().listen(name + "b",                                      wfeoh(boost::dcoroutines::make_callback(future), 1))); -    // skip the "post" part if requestPump is default-constructed -    if (requestPump) -    { -        // If either replyPumpNamePath is non-empty, store the corresponding -        // replyPump name in the request event. -        LLSD modevent(event);          storeToLLSDPath(modevent, replyPump0NamePath,                          replyPump0.getPump().getName());          storeToLLSDPath(modevent, replyPump1NamePath,                          replyPump1.getPump().getName()); -        LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name -                                 << " posting to " << requestPump.getPump().getName() -                                 << ": " << modevent << LL_ENDL; -        requestPump.getPump().post(modevent); -    } -    LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name -                             << " about to wait on LLEventPumps " << replyPump0.getPump().getName() -                             << ", " << replyPump1.getPump().getName() << LL_ENDL; -    // trying to dereference ("resolve") the future makes us wait for it -    LLEventWithID value; -    { -        // instantiate Suspending to manage "current" coroutine          llcoro::Suspending suspended; -        value = *future; -    } // destroy Suspending as soon as we're back -    LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name -                             << " resuming with (" << value.first << ", " << value.second << ")" -                             << LL_ENDL; -    // returning should disconnect both connections -    return value; -} -  LLSD errorException(const LLEventWithID& result, const std::string& desc)  {      // If the result arrived on the error pump (pump 1), instead of diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index e2ce4bb193..20fc422a68 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -101,6 +101,8 @@ VoidListener<LISTENER> voidlistener(const LISTENER& listener)      return VoidListener<LISTENER>(listener);  } +     * each distinct coroutine instance. +    std::string listenerNameForCoro();  /**   * Yield control from a coroutine for one "mainloop" tick. If your coroutine   * runs without suspending for nontrivial time, sprinkle in calls to this @@ -307,13 +309,13 @@ public:       */      LLSD wait()      { -        return llcoro::waitForEventOn(mPump); +        return ::waitForEventOn(mPump);      }      LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump,                       const LLSD& replyPumpNamePath=LLSD())      { -        return llcoro::postAndWait(event, requestPump, mPump, replyPumpNamePath); +        return ::postAndWait(event, requestPump, mPump, replyPumpNamePath);      }  private: @@ -352,19 +354,19 @@ public:      /// waitForEventOn(either of our two LLEventPumps)      LLEventWithID wait()      { -        return llcoro::waitForEventOn(mPump0, mPump1); +        return waitForEventOn(mPump0, mPump1);      }      /// errorException(wait())      LLSD waitWithException()      { -        return llcoro::errorException(wait(), std::string("Error event on ") + getName1()); +        return errorException(wait(), std::string("Error event on ") + getName1());      }      /// errorLog(wait())      LLSD waitWithLog()      { -        return llcoro::errorLog(wait(), std::string("Error event on ") + getName1()); +        return errorLog(wait(), std::string("Error event on ") + getName1());      }      LLEventWithID postAndWait(const LLSD& event, @@ -372,7 +374,7 @@ public:                                const LLSD& replyPump0NamePath=LLSD(),                                const LLSD& replyPump1NamePath=LLSD())      { -        return llcoro::postAndWait2(event, requestPump, mPump0, mPump1, +        return postAndWait2(event, requestPump, mPump0, mPump1,                                      replyPump0NamePath, replyPump1NamePath);      } @@ -381,7 +383,7 @@ public:                                    const LLSD& replyPump0NamePath=LLSD(),                                    const LLSD& replyPump1NamePath=LLSD())      { -        return llcoro::errorException(postAndWait(event, requestPump, +        return errorException(postAndWait(event, requestPump,                                                    replyPump0NamePath, replyPump1NamePath),                                        std::string("Error event on ") + getName1());      } @@ -391,7 +393,7 @@ public:                              const LLSD& replyPump0NamePath=LLSD(),                              const LLSD& replyPump1NamePath=LLSD())      { -        return llcoro::errorLog(postAndWait(event, requestPump, +        return errorLog(postAndWait(event, requestPump,                                              replyPump0NamePath, replyPump1NamePath),                                  std::string("Error event on ") + getName1());      } diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index 00be5035f2..b8d9d8002f 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -264,7 +264,8 @@ namespace tut          // Construct the coroutine instance that will run explicit_wait.          // Pass the ctor a callable that accepts the coroutine_type::self          // param passed by the library. -        boost::dcoroutines::coroutine<void()> coro(explicit_wait); +        boost::dcoroutines::coroutine<void()> +        coro(explicit_wait);          // Start the coroutine          coro(std::nothrow);          // When the coroutine waits for the event pump, it returns here. diff --git a/indra/llcorehttp/_httplibcurl.cpp b/indra/llcorehttp/_httplibcurl.cpp index 81b44ab90b..17e997688f 100755 --- a/indra/llcorehttp/_httplibcurl.cpp +++ b/indra/llcorehttp/_httplibcurl.cpp @@ -554,7 +554,7 @@ void HttpLibcurl::HandleCache::freeHandle(CURL * handle)  // --------------------------------------- -struct curl_slist * append_headers_to_slist(const HttpHeaders * headers, struct curl_slist * slist) +struct curl_slist * append_headers_to_slist(const HttpHeaders::ptr_t &headers, struct curl_slist * slist)  {  	const HttpHeaders::const_iterator end(headers->end());  	for (HttpHeaders::const_iterator it(headers->begin()); end != it; ++it) diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 799587ff22..e588ed8a9b 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -122,8 +122,8 @@ HttpOpRequest::HttpOpRequest()  	  mReqBody(NULL),  	  mReqOffset(0),  	  mReqLength(0), -	  mReqHeaders(NULL), -	  mReqOptions(NULL), +	  mReqHeaders(), +	  mReqOptions(),  	  mCurlActive(false),  	  mCurlHandle(NULL),  	  mCurlService(NULL), @@ -135,7 +135,7 @@ HttpOpRequest::HttpOpRequest()  	  mReplyOffset(0),  	  mReplyLength(0),  	  mReplyFullLength(0), -	  mReplyHeaders(NULL), +	  mReplyHeaders(),  	  mPolicyRetries(0),  	  mPolicy503Retries(0),  	  mPolicyRetryAt(HttpTime(0)), @@ -156,18 +156,6 @@ HttpOpRequest::~HttpOpRequest()  		mReqBody = NULL;  	} -	if (mReqOptions) -	{ -		mReqOptions->release(); -		mReqOptions = NULL; -	} - -	if (mReqHeaders) -	{ -		mReqHeaders->release(); -		mReqHeaders = NULL; -	} -  	if (mCurlHandle)  	{  		// Uncertain of thread context so free using @@ -194,11 +182,6 @@ HttpOpRequest::~HttpOpRequest()  		mReplyBody = NULL;  	} -	if (mReplyHeaders) -	{ -		mReplyHeaders->release(); -		mReplyHeaders = NULL; -	}  } @@ -298,8 +281,8 @@ HttpStatus HttpOpRequest::cancel()  HttpStatus HttpOpRequest::setupGet(HttpRequest::policy_t policy_id,  								   HttpRequest::priority_t priority,  								   const std::string & url, -								   HttpOptions * options, -								   HttpHeaders * headers) +                                   const HttpOptions::ptr_t & options, +								   const HttpHeaders::ptr_t & headers)  {  	setupCommon(policy_id, priority, url, NULL, options, headers);  	mReqMethod = HOR_GET; @@ -313,8 +296,8 @@ HttpStatus HttpOpRequest::setupGetByteRange(HttpRequest::policy_t policy_id,  											const std::string & url,  											size_t offset,  											size_t len, -											HttpOptions * options, -											HttpHeaders * headers) +                                            const HttpOptions::ptr_t & options, +                                            const HttpHeaders::ptr_t & headers)  {  	setupCommon(policy_id, priority, url, NULL, options, headers);  	mReqMethod = HOR_GET; @@ -333,8 +316,8 @@ HttpStatus HttpOpRequest::setupPost(HttpRequest::policy_t policy_id,  									HttpRequest::priority_t priority,  									const std::string & url,  									BufferArray * body, -									HttpOptions * options, -									HttpHeaders * headers) +                                    const HttpOptions::ptr_t & options, +                                    const HttpHeaders::ptr_t & headers)  {  	setupCommon(policy_id, priority, url, body, options, headers);  	mReqMethod = HOR_POST; @@ -347,8 +330,8 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id,  								   HttpRequest::priority_t priority,  								   const std::string & url,  								   BufferArray * body, -								   HttpOptions * options, -								   HttpHeaders * headers) +                                   const HttpOptions::ptr_t & options, +								   const HttpHeaders::ptr_t & headers)  {  	setupCommon(policy_id, priority, url, body, options, headers);  	mReqMethod = HOR_PUT; @@ -360,8 +343,8 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id,  HttpStatus HttpOpRequest::setupDelete(HttpRequest::policy_t policy_id,      HttpRequest::priority_t priority,      const std::string & url, -    HttpOptions * options, -    HttpHeaders * headers) +    const HttpOptions::ptr_t & options, +    const HttpHeaders::ptr_t & headers)  {      setupCommon(policy_id, priority, url, NULL, options, headers);      mReqMethod = HOR_DELETE; @@ -374,8 +357,8 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id,      HttpRequest::priority_t priority,      const std::string & url,      BufferArray * body, -    HttpOptions * options, -    HttpHeaders * headers) +    const HttpOptions::ptr_t & options, +    const HttpHeaders::ptr_t & headers)  {      setupCommon(policy_id, priority, url, body, options, headers);      mReqMethod = HOR_PATCH; @@ -387,8 +370,8 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id,  HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id,      HttpRequest::priority_t priority,      const std::string & url, -    HttpOptions * options, -    HttpHeaders * headers) +    const HttpOptions::ptr_t & options, +    const HttpHeaders::ptr_t &headers)  {      setupCommon(policy_id, priority, url, NULL, options, headers);      mReqMethod = HOR_COPY; @@ -401,8 +384,8 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id,  								HttpRequest::priority_t priority,  								const std::string & url,  								BufferArray * body, -								HttpOptions * options, -								HttpHeaders * headers) +                                const HttpOptions::ptr_t & options, +								const HttpHeaders::ptr_t & headers)  {  	mProcFlags = 0U;  	mReqPolicy = policy_id; @@ -415,12 +398,10 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id,  	}  	if (headers && ! mReqHeaders)  	{ -		headers->addRef();  		mReqHeaders = headers;  	} -	if (options && ! mReqOptions) +	if (options && !mReqOptions)  	{ -		options->addRef();  		mReqOptions = options;  		if (options->getWantHeaders())  		{ @@ -467,11 +448,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)  	mReplyOffset = 0;  	mReplyLength = 0;  	mReplyFullLength = 0; -	if (mReplyHeaders) -	{ -		mReplyHeaders->release(); -		mReplyHeaders = NULL; -	} +    mReplyHeaders.reset();  	mReplyConType.clear();  	// *FIXME:  better error handling later @@ -946,7 +923,7 @@ size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, voi  		// Save headers in response  		if (! op->mReplyHeaders)  		{ -			op->mReplyHeaders = new HttpHeaders; +			op->mReplyHeaders = HttpHeaders::ptr_t(new HttpHeaders);  		}  		op->mReplyHeaders->append(name, value ? value : "");  	} diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index b1bb101bea..a9083be02b 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -41,14 +41,14 @@  #include "_httpoperation.h"  #include "_refcounted.h" +#include "httpheaders.h" +#include "httpoptions.h"  namespace LLCore  {  class BufferArray; -class HttpHeaders; -class HttpOptions;  /// HttpOpRequest requests a supported HTTP method invocation with @@ -104,49 +104,49 @@ public:  	HttpStatus setupGet(HttpRequest::policy_t policy_id,  						HttpRequest::priority_t priority,  						const std::string & url, -						HttpOptions * options, -						HttpHeaders * headers); +						const HttpOptions::ptr_t & options, +						const HttpHeaders::ptr_t & headers);  	HttpStatus setupGetByteRange(HttpRequest::policy_t policy_id,  								 HttpRequest::priority_t priority,  								 const std::string & url,  								 size_t offset,  								 size_t len, -								 HttpOptions * options, -								 HttpHeaders * headers); +                                 const HttpOptions::ptr_t & options, +								 const HttpHeaders::ptr_t & headers);  	HttpStatus setupPost(HttpRequest::policy_t policy_id,  						 HttpRequest::priority_t priority,  						 const std::string & url,  						 BufferArray * body, -						 HttpOptions * options, -						 HttpHeaders * headers); +                         const HttpOptions::ptr_t & options, +						 const HttpHeaders::ptr_t & headers);  	HttpStatus setupPut(HttpRequest::policy_t policy_id,  						HttpRequest::priority_t priority,  						const std::string & url,  						BufferArray * body, -						HttpOptions * options, -						HttpHeaders * headers); +                        const HttpOptions::ptr_t & options, +						const HttpHeaders::ptr_t & headers);      HttpStatus setupDelete(HttpRequest::policy_t policy_id,                          HttpRequest::priority_t priority,                          const std::string & url, -                        HttpOptions * options, -                        HttpHeaders * headers); +                        const HttpOptions::ptr_t & options, +                        const HttpHeaders::ptr_t & headers);      HttpStatus setupPatch(HttpRequest::policy_t policy_id,                          HttpRequest::priority_t priority,                          const std::string & url,                          BufferArray * body, -                        HttpOptions * options, -                        HttpHeaders * headers); +                        const HttpOptions::ptr_t & options, +                        const HttpHeaders::ptr_t & headers);      HttpStatus setupCopy(HttpRequest::policy_t policy_id,                          HttpRequest::priority_t priority,                          const std::string & url, -                        HttpOptions * options, -                        HttpHeaders * headers); +                        const HttpOptions::ptr_t & options, +                        const HttpHeaders::ptr_t & headers);      // Internal method used to setup the libcurl options for a request.  	// Does all the libcurl handle setup in one place. @@ -166,8 +166,8 @@ protected:  					 HttpRequest::priority_t priority,  					 const std::string & url,  					 BufferArray * body, -					 HttpOptions * options, -					 HttpHeaders * headers); +                     const HttpOptions::ptr_t & options, +					 const HttpHeaders::ptr_t & headers);  	// libcurl operational callbacks  	// @@ -197,8 +197,8 @@ public:  	BufferArray *		mReqBody;  	off_t				mReqOffset;  	size_t				mReqLength; -	HttpHeaders *		mReqHeaders; -	HttpOptions *		mReqOptions; +	HttpHeaders::ptr_t	mReqHeaders; +    HttpOptions::ptr_t  mReqOptions;  	// Transport data  	bool				mCurlActive; @@ -215,7 +215,7 @@ public:  	off_t				mReplyOffset;  	size_t				mReplyLength;  	size_t				mReplyFullLength; -	HttpHeaders *		mReplyHeaders; +	HttpHeaders::ptr_t	mReplyHeaders;  	std::string			mReplyConType;  	int					mReplyRetryAfter; @@ -246,7 +246,7 @@ public:  // Internal function to append the contents of an HttpHeaders  // instance to a curl_slist object. -curl_slist * append_headers_to_slist(const HttpHeaders *, curl_slist * slist); +curl_slist * append_headers_to_slist(const HttpHeaders::ptr_t &, curl_slist * slist);  }   // end namespace LLCore diff --git a/indra/llcorehttp/examples/http_texture_load.cpp b/indra/llcorehttp/examples/http_texture_load.cpp index 9d9631b980..737282c7df 100755 --- a/indra/llcorehttp/examples/http_texture_load.cpp +++ b/indra/llcorehttp/examples/http_texture_load.cpp @@ -83,7 +83,7 @@ public:  	WorkingSet();  	~WorkingSet(); -	bool reload(LLCore::HttpRequest *, LLCore::HttpOptions *); +	bool reload(LLCore::HttpRequest *, LLCore::HttpOptions::ptr_t &);  	virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); @@ -121,7 +121,7 @@ public:  	int							mRetriesHttp503;  	int							mSuccesses;  	long						mByteCount; -	LLCore::HttpHeaders *		mHeaders; +	LLCore::HttpHeaders::ptr_t	mHeaders;  }; @@ -304,7 +304,7 @@ int main(int argc, char** argv)  	LLCore::HttpRequest * hr = new LLCore::HttpRequest();  	// Get request options -	LLCore::HttpOptions * opt = new LLCore::HttpOptions(); +	LLCore::HttpOptions::ptr_t opt = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions());  	opt->setRetries(12);  	opt->setUseRetryAfter(true); @@ -363,8 +363,7 @@ int main(int argc, char** argv)  	// Clean up  	hr->requestStopThread(NULL);  	ms_sleep(1000); -	opt->release(); -	opt = NULL; +    opt.reset();  	delete hr;  	LLCore::HttpRequest::destroyService();  	term_curl(); @@ -427,22 +426,17 @@ WorkingSet::WorkingSet()  {  	mAssets.reserve(30000); -	mHeaders = new LLCore::HttpHeaders; +	mHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);  	mHeaders->append("Accept", "image/x-j2c");  }  WorkingSet::~WorkingSet()  { -	if (mHeaders) -	{ -		mHeaders->release(); -		mHeaders = NULL; -	}  } -bool WorkingSet::reload(LLCore::HttpRequest * hr, LLCore::HttpOptions * opt) +bool WorkingSet::reload(LLCore::HttpRequest * hr, LLCore::HttpOptions::ptr_t & opt)  {  	if (mRequestLowWater <= mHandles.size())  	{ diff --git a/indra/llcorehttp/httpheaders.cpp b/indra/llcorehttp/httpheaders.cpp index e03b1b080d..f586191a7c 100755 --- a/indra/llcorehttp/httpheaders.cpp +++ b/indra/llcorehttp/httpheaders.cpp @@ -34,7 +34,6 @@ namespace LLCore  HttpHeaders::HttpHeaders() -	: RefCounted(true)  {} diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h index 8f14568fa3..b9168cb6ec 100755 --- a/indra/llcorehttp/httpheaders.h +++ b/indra/llcorehttp/httpheaders.h @@ -74,7 +74,7 @@ namespace LLCore  /// constructor is given a refcount.  /// -class HttpHeaders : public LLCoreInt::RefCounted +class HttpHeaders: private boost::noncopyable  {  public:  	typedef std::pair<std::string, std::string> header_t; @@ -85,16 +85,17 @@ public:  	typedef container_t::const_reverse_iterator const_reverse_iterator;  	typedef container_t::value_type value_type;  	typedef container_t::size_type size_type; +    typedef boost::shared_ptr<HttpHeaders> ptr_t;  public:  	/// @post In addition to the instance, caller has a refcount  	/// to the instance.  A call to @see release() will destroy  	/// the instance.  	HttpHeaders(); +    virtual ~HttpHeaders();						// Use release() -	typedef LLCoreInt::IntrusivePtr<HttpHeaders> ptr_t; +	//typedef LLCoreInt::IntrusivePtr<HttpHeaders> ptr_t;  protected: -	virtual ~HttpHeaders();						// Use release()  	HttpHeaders(const HttpHeaders &);			// Not defined  	void operator=(const HttpHeaders &);		// Not defined diff --git a/indra/llcorehttp/httpoptions.cpp b/indra/llcorehttp/httpoptions.cpp index 3459a37aff..aab447f2dd 100755 --- a/indra/llcorehttp/httpoptions.cpp +++ b/indra/llcorehttp/httpoptions.cpp @@ -33,7 +33,7 @@ namespace LLCore  { -HttpOptions::HttpOptions() : RefCounted(true), +HttpOptions::HttpOptions() :      mWantHeaders(false),      mTracing(HTTP_TRACE_OFF),      mTimeout(HTTP_REQUEST_TIMEOUT_DEFAULT), diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h index 2fe05a65ff..510eaa45bb 100755 --- a/indra/llcorehttp/httpoptions.h +++ b/indra/llcorehttp/httpoptions.h @@ -55,15 +55,16 @@ namespace LLCore  /// Allocation:  Refcounted, heap only.  Caller of the constructor  /// is given a refcount.  /// -class HttpOptions : public LLCoreInt::RefCounted +class HttpOptions : private boost::noncopyable  {  public:  	HttpOptions(); -	typedef LLCoreInt::IntrusivePtr<HttpOptions> ptr_t; +	typedef boost::shared_ptr<HttpOptions> ptr_t; + +    virtual ~HttpOptions();						// Use release()  protected: -	virtual ~HttpOptions();						// Use release()  	HttpOptions(const HttpOptions &);			// Not defined  	void operator=(const HttpOptions &);		// Not defined diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index d4c60a6f14..f0dfde6153 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -197,8 +197,8 @@ HttpStatus HttpRequest::getStatus() const  HttpHandle HttpRequest::requestGet(policy_t policy_id,  								   priority_t priority,  								   const std::string & url, -								   HttpOptions * options, -								   HttpHeaders * headers, +                                   const HttpOptions::ptr_t & options, +								   const HttpHeaders::ptr_t & headers,  								   HttpHandler * user_handler)  {  	HttpStatus status; @@ -231,8 +231,8 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id,  											const std::string & url,  											size_t offset,  											size_t len, -											HttpOptions * options, -											HttpHeaders * headers, +                                            const HttpOptions::ptr_t & options, +											const HttpHeaders::ptr_t & headers,  											HttpHandler * user_handler)  {  	HttpStatus status; @@ -264,8 +264,8 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id,  									priority_t priority,  									const std::string & url,  									BufferArray * body, -									HttpOptions * options, -									HttpHeaders * headers, +                                    const HttpOptions::ptr_t & options, +									const HttpHeaders::ptr_t & headers,  									HttpHandler * user_handler)  {  	HttpStatus status; @@ -297,8 +297,8 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id,  								   priority_t priority,  								   const std::string & url,  								   BufferArray * body, -								   HttpOptions * options, -								   HttpHeaders * headers, +                                   const HttpOptions::ptr_t & options, +								   const HttpHeaders::ptr_t & headers,  								   HttpHandler * user_handler)  {  	HttpStatus status; @@ -328,8 +328,8 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id,  HttpHandle HttpRequest::requestDelete(policy_t policy_id,      priority_t priority,      const std::string & url, -    HttpOptions * options, -    HttpHeaders * headers, +    const HttpOptions::ptr_t & options, +    const HttpHeaders::ptr_t & headers,      HttpHandler * user_handler)  {      HttpStatus status; @@ -360,8 +360,8 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id,      priority_t priority,      const std::string & url,      BufferArray * body, -    HttpOptions * options, -    HttpHeaders * headers, +    const HttpOptions::ptr_t & options, +    const HttpHeaders::ptr_t & headers,      HttpHandler * user_handler)  {      HttpStatus status; @@ -391,8 +391,8 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id,  HttpHandle HttpRequest::requestCopy(policy_t policy_id,      priority_t priority,      const std::string & url, -    HttpOptions * options, -    HttpHeaders * headers, +    const HttpOptions::ptr_t & options, +    const HttpHeaders::ptr_t & headers,      HttpHandler * user_handler)  {      HttpStatus status; diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index e87a8b691a..20a223c482 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -31,6 +31,8 @@  #include "httpcommon.h"  #include "httphandler.h" +#include "httpheaders.h" +#include "httpoptions.h"  namespace LLCore  { @@ -38,8 +40,6 @@ namespace LLCore  class HttpRequestQueue;  class HttpReplyQueue;  class HttpService; -class HttpOptions; -class HttpHeaders;  class HttpOperation;  class BufferArray; @@ -348,8 +348,8 @@ public:  	HttpHandle requestGet(policy_t policy_id,  						  priority_t priority,  						  const std::string & url, -						  HttpOptions * options, -						  HttpHeaders * headers, +                          const HttpOptions::ptr_t & options, +						  const HttpHeaders::ptr_t & headers,  						  HttpHandler * handler); @@ -391,8 +391,8 @@ public:  								   const std::string & url,  								   size_t offset,  								   size_t len, -								   HttpOptions * options, -								   HttpHeaders * headers, +                                   const HttpOptions::ptr_t & options, +								   const HttpHeaders::ptr_t & headers,  								   HttpHandler * handler); @@ -432,8 +432,8 @@ public:  						   priority_t priority,  						   const std::string & url,  						   BufferArray * body, -						   HttpOptions * options, -						   HttpHeaders * headers, +                           const HttpOptions::ptr_t & options, +						   const HttpHeaders::ptr_t & headers,  						   HttpHandler * handler); @@ -473,8 +473,8 @@ public:  						  priority_t priority,  						  const std::string & url,  						  BufferArray * body, -						  HttpOptions * options, -						  HttpHeaders * headers, +                          const HttpOptions::ptr_t & options, +						  const HttpHeaders::ptr_t & headers,  						  HttpHandler * handler); @@ -493,8 +493,8 @@ public:      HttpHandle requestDelete(policy_t policy_id,              priority_t priority,              const std::string & url, -            HttpOptions * options, -            HttpHeaders * headers, +            const HttpOptions::ptr_t & options, +            const HttpHeaders::ptr_t & headers,              HttpHandler * user_handler);      /// Queue a full HTTP PUT.  Query arguments and body may @@ -516,8 +516,8 @@ public:              priority_t priority,              const std::string & url,              BufferArray * body, -            HttpOptions * options, -            HttpHeaders * headers, +            const HttpOptions::ptr_t & options, +            const HttpHeaders::ptr_t & headers,              HttpHandler * user_handler);      /// Queue a full HTTP PUT.  Query arguments and body may @@ -535,8 +535,8 @@ public:      HttpHandle requestCopy(policy_t policy_id,              priority_t priority,              const std::string & url, -            HttpOptions * options, -            HttpHeaders * headers, +            const HttpOptions::ptr_t & options, +            const HttpHeaders::ptr_t & headers,              HttpHandler * user_handler);      /// Queue a NoOp request. diff --git a/indra/llcorehttp/httpresponse.cpp b/indra/llcorehttp/httpresponse.cpp index 7d88f02527..f5ad2ebd47 100755 --- a/indra/llcorehttp/httpresponse.cpp +++ b/indra/llcorehttp/httpresponse.cpp @@ -39,7 +39,7 @@ HttpResponse::HttpResponse()  	  mReplyLength(0U),  	  mReplyFullLength(0U),  	  mBufferArray(NULL), -	  mHeaders(NULL), +	  mHeaders(),  	  mRetries(0U),  	  m503Retries(0U),        mRequestUrl() @@ -49,7 +49,7 @@ HttpResponse::HttpResponse()  HttpResponse::~HttpResponse()  {  	setBody(NULL); -	setHeaders(NULL); +	//setHeaders();  } @@ -72,22 +72,9 @@ void HttpResponse::setBody(BufferArray * ba)  } -void HttpResponse::setHeaders(HttpHeaders * headers) +void HttpResponse::setHeaders(HttpHeaders::ptr_t &headers)  { -	if (mHeaders == headers) -		return; -	 -	if (mHeaders) -	{ -		mHeaders->release(); -	} - -	if (headers) -	{ -		headers->addRef(); -	} -	 -	mHeaders = headers; +    mHeaders = headers;  }  size_t HttpResponse::getBodySize() const diff --git a/indra/llcorehttp/httpresponse.h b/indra/llcorehttp/httpresponse.h index 6c3b4da5e6..0bfa4585c7 100755 --- a/indra/llcorehttp/httpresponse.h +++ b/indra/llcorehttp/httpresponse.h @@ -31,7 +31,7 @@  #include <string>  #include "httpcommon.h" - +#include "httpheaders.h"  #include "_refcounted.h" @@ -120,13 +120,13 @@ public:  	///  	/// Caller can hold onto the headers by incrementing the reference  	/// count of the returned object. -	HttpHeaders * getHeaders() const -		{ +	HttpHeaders::ptr_t getHeaders() const +	{  			return mHeaders; -		} +	}  	/// Behaves like @see setResponse() but for header data. -	void setHeaders(HttpHeaders * headers); +	void setHeaders(HttpHeaders::ptr_t &headers);  	/// If a 'Range:' header was used, these methods are involved  	/// in setting and returning data about the actual response. @@ -212,7 +212,7 @@ protected:  	unsigned int		mReplyLength;  	unsigned int		mReplyFullLength;  	BufferArray *		mBufferArray; -	HttpHeaders *		mHeaders; +	HttpHeaders::ptr_t	mHeaders;  	std::string			mContentType;  	unsigned int		mRetries;  	unsigned int		m503Retries; diff --git a/indra/llcorehttp/tests/test_httpheaders.hpp b/indra/llcorehttp/tests/test_httpheaders.hpp index 668c36dc66..c05f1d9429 100755 --- a/indra/llcorehttp/tests/test_httpheaders.hpp +++ b/indra/llcorehttp/tests/test_httpheaders.hpp @@ -59,13 +59,12 @@ void HttpHeadersTestObjectType::test<1>()  	mMemTotal = GetMemTotal();  	// create a new ref counted object with an implicit reference -	HttpHeaders * headers = new HttpHeaders(); -	ensure("One ref on construction of HttpHeaders", headers->getRefCount() == 1); +	HttpHeaders::ptr_t headers = HttpHeaders::ptr_t(new HttpHeaders());  	ensure("Memory being used", mMemTotal < GetMemTotal());  	ensure("Nothing in headers", 0 == headers->size());  	// release the implicit reference, causing the object to be released -	headers->release(); +    headers.reset();  	// make sure we didn't leak any memory  	ensure(mMemTotal == GetMemTotal()); @@ -80,7 +79,7 @@ void HttpHeadersTestObjectType::test<2>()  	mMemTotal = GetMemTotal();  	// create a new ref counted object with an implicit reference -	HttpHeaders * headers = new HttpHeaders(); +	HttpHeaders::ptr_t headers = HttpHeaders::ptr_t(new HttpHeaders());  	{  		// Append a few strings @@ -101,7 +100,7 @@ void HttpHeadersTestObjectType::test<2>()  	}  	// release the implicit reference, causing the object to be released -	headers->release(); +    headers.reset();  	// make sure we didn't leak any memory  	ensure(mMemTotal == GetMemTotal()); @@ -116,7 +115,7 @@ void HttpHeadersTestObjectType::test<3>()  	mMemTotal = GetMemTotal();  	// create a new ref counted object with an implicit reference -	HttpHeaders * headers = new HttpHeaders(); +	HttpHeaders::ptr_t headers = HttpHeaders::ptr_t(new HttpHeaders());  	{  		// Append a few strings @@ -151,7 +150,7 @@ void HttpHeadersTestObjectType::test<3>()  	}  	// release the implicit reference, causing the object to be released -	headers->release(); +    headers.reset();  	// make sure we didn't leak any memory  	ensure(mMemTotal == GetMemTotal()); @@ -166,8 +165,8 @@ void HttpHeadersTestObjectType::test<4>()  	mMemTotal = GetMemTotal();  	// create a new ref counted object with an implicit reference -	HttpHeaders * headers = new HttpHeaders(); -	 +    HttpHeaders::ptr_t headers = HttpHeaders::ptr_t(new HttpHeaders()); +  	{  		static char line1[] = " AcCePT : image/yourfacehere";  		static char line1v[] = "image/yourfacehere"; @@ -251,7 +250,7 @@ void HttpHeadersTestObjectType::test<4>()  	}  	// release the implicit reference, causing the object to be released -	headers->release(); +    headers.reset();  	// make sure we didn't leak any memory  	ensure(mMemTotal == GetMemTotal()); @@ -267,7 +266,7 @@ void HttpHeadersTestObjectType::test<5>()  	mMemTotal = GetMemTotal();  	// create a new ref counted object with an implicit reference -	HttpHeaders * headers = new HttpHeaders(); +    HttpHeaders::ptr_t headers = HttpHeaders::ptr_t(new HttpHeaders());  	HttpHeaders::iterator end(headers->end()), begin(headers->begin());  	ensure("Empty container has equal begin/end const iterators", end == begin); @@ -337,7 +336,7 @@ void HttpHeadersTestObjectType::test<5>()  	}  	// release the implicit reference, causing the object to be released -	headers->release(); +    headers.reset();  	// make sure we didn't leak any memory  	ensure(mMemTotal == GetMemTotal()); @@ -353,7 +352,7 @@ void HttpHeadersTestObjectType::test<6>()  	mMemTotal = GetMemTotal();  	// create a new ref counted object with an implicit reference -	HttpHeaders * headers = new HttpHeaders(); +    HttpHeaders::ptr_t headers = HttpHeaders::ptr_t(new HttpHeaders());  	HttpHeaders::reverse_iterator rend(headers->rend()), rbegin(headers->rbegin());  	ensure("Empty container has equal rbegin/rend const iterators", rend == rbegin); @@ -421,7 +420,7 @@ void HttpHeadersTestObjectType::test<6>()  	}  	// release the implicit reference, causing the object to be released -	headers->release(); +    headers.reset();  	// make sure we didn't leak any memory  	ensure(mMemTotal == GetMemTotal()); diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index 43f7e36da5..1f606bd0c1 100755 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -112,7 +112,7 @@ public:  			if (! mHeadersRequired.empty() || ! mHeadersDisallowed.empty())  			{  				ensure("Response required with header check", response != NULL); -				HttpHeaders * header(response->getHeaders());	// Will not hold onto this +				HttpHeaders::ptr_t header(response->getHeaders());	// Will not hold onto this  				ensure("Some quantity of headers returned", header != NULL);  				if (! mHeadersRequired.empty()) @@ -638,7 +638,7 @@ void HttpRequestTestObjectType::test<7>()  	mHandlerCalls = 0;  	HttpRequest * req = NULL; -	HttpOptions * opts = NULL; +	HttpOptions::ptr_t opts;  	try  	{ @@ -653,7 +653,7 @@ void HttpRequestTestObjectType::test<7>()  		req = new HttpRequest();  		ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); -		opts = new HttpOptions(); +        opts = HttpOptions::ptr_t(new HttpOptions());  		opts->setRetries(1);			// Don't try for too long - default retries take about 18S  		// Issue a GET that can't connect @@ -664,7 +664,7 @@ void HttpRequestTestObjectType::test<7>()  													 0,  													 0,  													 opts, -													 NULL, +													 HttpHeaders::ptr_t(),  													 &handler);  		ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -705,8 +705,7 @@ void HttpRequestTestObjectType::test<7>()  		ensure("Thread actually stopped running", HttpService::isStopped());  		// release options -		opts->release(); -		opts = NULL; +        opts.reset();  		// release the request object  		delete req; @@ -728,11 +727,7 @@ void HttpRequestTestObjectType::test<7>()  	catch (...)  	{  		stop_thread(req); -		if (opts) -		{ -			opts->release(); -			opts = NULL; -		} +        opts.reset();  		delete req;  		HttpRequest::destroyService();  		throw; @@ -779,8 +774,8 @@ void HttpRequestTestObjectType::test<8>()  		HttpHandle handle = req->requestGet(HttpRequest::DEFAULT_POLICY_ID,  											0U,  											url_base, -											NULL, -											NULL, +											HttpOptions::ptr_t(), +                                            HttpHeaders::ptr_t(),  											&handler);  		ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -889,8 +884,8 @@ void HttpRequestTestObjectType::test<9>()  													 url_base,  													 0,  													 0, -													 NULL, -													 NULL, +													 HttpOptions::ptr_t(), +                                                     HttpHeaders::ptr_t(),  													 &handler);  		ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -1001,9 +996,9 @@ void HttpRequestTestObjectType::test<10>()  											0U,  											url_base,  											body, -											NULL, -											NULL, -											&handler); +                                            HttpOptions::ptr_t(), +                                            HttpHeaders::ptr_t(), +                                            &handler);  		ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID);  		// Run the notification pump. @@ -1119,9 +1114,9 @@ void HttpRequestTestObjectType::test<11>()  											 0U,  											 url_base,  											 body, -											 NULL, -											 NULL, -											 &handler); +                                             HttpOptions::ptr_t(), +                                             HttpHeaders::ptr_t(), +                                             &handler);  		ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID);  		// Run the notification pump. @@ -1239,9 +1234,9 @@ void HttpRequestTestObjectType::test<12>()  													 url_base,  													 0,  													 0, -													 NULL, -													 NULL, -													 &handler); +                                                     HttpOptions::ptr_t(), +                                                     HttpHeaders::ptr_t(), +                                                     &handler);  		ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID);  		// Run the notification pump. @@ -1332,7 +1327,7 @@ void HttpRequestTestObjectType::test<13>()  	mHandlerCalls = 0;  	HttpRequest * req = NULL; -	HttpOptions * opts = NULL; +	HttpOptions::ptr_t opts;  	try  	{ @@ -1350,7 +1345,7 @@ void HttpRequestTestObjectType::test<13>()  		req = new HttpRequest();  		ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); -		opts = new HttpOptions(); +        opts = HttpOptions::ptr_t(new HttpOptions());  		opts->setWantHeaders(true);  		// Issue a GET that succeeds @@ -1364,13 +1359,12 @@ void HttpRequestTestObjectType::test<13>()  													 0,	  												 0,  													 opts, -													 NULL, -													 &handler); +                                                     HttpHeaders::ptr_t(), +                                                     &handler);  		ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID);  		// release options -		opts->release(); -		opts = NULL; +        opts.reset();  		// Run the notification pump.  		int count(0); @@ -1430,11 +1424,7 @@ void HttpRequestTestObjectType::test<13>()  	catch (...)  	{  		stop_thread(req); -		if (opts) -		{ -			opts->release(); -			opts = NULL; -		} +        opts.reset();  		delete req;  		HttpRequest::destroyService();  		throw; @@ -1460,7 +1450,7 @@ void HttpRequestTestObjectType::test<14>()  	mHandlerCalls = 0;  	HttpRequest * req = NULL; -	HttpOptions * opts = NULL; +	HttpOptions::ptr_t opts;  	try  	{ @@ -1475,7 +1465,7 @@ void HttpRequestTestObjectType::test<14>()  		req = new HttpRequest();  		ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); -		opts = new HttpOptions(); +        opts = HttpOptions::ptr_t(new HttpOptions);  		opts->setRetries(0);			// Don't retry  		opts->setTimeout(2); @@ -1487,8 +1477,8 @@ void HttpRequestTestObjectType::test<14>()  													 0,  													 0,  													 opts, -													 NULL, -													 &handler); +                                                     HttpHeaders::ptr_t(), +                                                     &handler);  		ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID);  		// Run the notification pump. @@ -1528,8 +1518,7 @@ void HttpRequestTestObjectType::test<14>()  		ensure("Thread actually stopped running", HttpService::isStopped());  		// release options -		opts->release(); -		opts = NULL; +        opts.reset();  		// release the request object  		delete req; @@ -1552,11 +1541,7 @@ void HttpRequestTestObjectType::test<14>()  	catch (...)  	{  		stop_thread(req); -		if (opts) -		{ -			opts->release(); -			opts = NULL; -		} +        opts.reset();  		delete req;  		HttpRequest::destroyService();  		throw; @@ -1609,9 +1594,9 @@ void HttpRequestTestObjectType::test<15>()  		HttpHandle handle = req->requestGet(HttpRequest::DEFAULT_POLICY_ID,  											0U,  											url_base, -											NULL, -											NULL, -											&handler); +                                            HttpOptions::ptr_t(), +                                            HttpHeaders::ptr_t(), +                                            &handler);  		ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID);  		// Run the notification pump. @@ -1703,8 +1688,8 @@ void HttpRequestTestObjectType::test<16>()  	mHandlerCalls = 0;  	HttpRequest * req = NULL; -	HttpOptions * options = NULL; -	HttpHeaders * headers = NULL; +	HttpOptions::ptr_t options; +	HttpHeaders::ptr_t headers;  	try  	{ @@ -1719,7 +1704,7 @@ void HttpRequestTestObjectType::test<16>()  		req = new HttpRequest();  		// options set -		options = new HttpOptions(); +        options = HttpOptions::ptr_t(new HttpOptions());  		options->setWantHeaders(true);  		// Issue a GET that *can* connect @@ -1776,7 +1761,7 @@ void HttpRequestTestObjectType::test<16>()  											0U,  											url_base + "reflect/",  											options, -											NULL, +											HttpHeaders::ptr_t(),  											&handler);  		ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -1792,7 +1777,7 @@ void HttpRequestTestObjectType::test<16>()  		ensure("One handler invocation for request", mHandlerCalls == 1);  		// Do a texture-style fetch -		headers = new HttpHeaders; +		headers = HttpHeaders::ptr_t(new HttpHeaders);  		headers->append("Accept", "image/x-j2c");  		mStatus = HttpStatus(200); @@ -1897,17 +1882,8 @@ void HttpRequestTestObjectType::test<16>()  		ensure("Thread actually stopped running", HttpService::isStopped());  		// release options & headers -		if (options) -		{ -			options->release(); -		} -		options = NULL; - -		if (headers) -		{ -			headers->release(); -		} -		headers = NULL; +        options.reset(); +        headers.reset();  		// release the request object  		delete req; @@ -1919,16 +1895,9 @@ void HttpRequestTestObjectType::test<16>()  	catch (...)  	{  		stop_thread(req); -		if (options) -		{ -			options->release(); -			options = NULL; -		} -		if (headers) -		{ -			headers->release(); -			headers = NULL; -		} +        options.reset(); +        headers.reset(); +  		delete req;  		HttpRequest::destroyService();  		throw; @@ -1960,8 +1929,8 @@ void HttpRequestTestObjectType::test<17>()  	mHandlerCalls = 0;  	HttpRequest * req = NULL; -	HttpOptions * options = NULL; -	HttpHeaders * headers = NULL; +	HttpOptions::ptr_t options; +	HttpHeaders::ptr_t headers;  	BufferArray * ba = NULL;  	try @@ -1977,7 +1946,7 @@ void HttpRequestTestObjectType::test<17>()  		req = new HttpRequest();  		// options set -		options = new HttpOptions(); +        options = HttpOptions::ptr_t(new HttpOptions());  		options->setWantHeaders(true);  		// And a buffer array @@ -2049,7 +2018,7 @@ void HttpRequestTestObjectType::test<17>()  											 url_base + "reflect/",  											 ba,  											 options, -											 NULL, +											 HttpHeaders::ptr_t(),  											 &handler);  		ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID);  		ba->release(); @@ -2095,17 +2064,8 @@ void HttpRequestTestObjectType::test<17>()  		ensure("Thread actually stopped running", HttpService::isStopped());  		// release options & headers -		if (options) -		{ -			options->release(); -		} -		options = NULL; - -		if (headers) -		{ -			headers->release(); -		} -		headers = NULL; +        options.reset(); +        headers.reset();  		// release the request object  		delete req; @@ -2122,17 +2082,10 @@ void HttpRequestTestObjectType::test<17>()  			ba->release();  			ba = NULL;  		} -		if (options) -		{ -			options->release(); -			options = NULL; -		} -		if (headers) -		{ -			headers->release(); -			headers = NULL; -		} -		delete req; +        options.reset(); +        headers.reset(); + +        delete req;  		HttpRequest::destroyService();  		throw;  	} @@ -2163,8 +2116,8 @@ void HttpRequestTestObjectType::test<18>()  	mHandlerCalls = 0;  	HttpRequest * req = NULL; -	HttpOptions * options = NULL; -	HttpHeaders * headers = NULL; +	HttpOptions::ptr_t options; +	HttpHeaders::ptr_t headers;  	BufferArray * ba = NULL;  	try @@ -2180,7 +2133,7 @@ void HttpRequestTestObjectType::test<18>()  		req = new HttpRequest();  		// options set -		options = new HttpOptions(); +		options = HttpOptions::ptr_t(new HttpOptions());  		options->setWantHeaders(true);  		// And a buffer array @@ -2253,7 +2206,7 @@ void HttpRequestTestObjectType::test<18>()  											url_base + "reflect/",  											ba,  											options, -											NULL, +											HttpHeaders::ptr_t(),  											&handler);  		ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID);  		ba->release(); @@ -2299,17 +2252,8 @@ void HttpRequestTestObjectType::test<18>()  		ensure("Thread actually stopped running", HttpService::isStopped());  		// release options & headers -		if (options) -		{ -			options->release(); -		} -		options = NULL; - -		if (headers) -		{ -			headers->release(); -		} -		headers = NULL; +        options.reset(); +        headers.reset();  		// release the request object  		delete req; @@ -2326,17 +2270,10 @@ void HttpRequestTestObjectType::test<18>()  			ba->release();  			ba = NULL;  		} -		if (options) -		{ -			options->release(); -			options = NULL; -		} -		if (headers) -		{ -			headers->release(); -			headers = NULL; -		} -		delete req; +        options.reset(); +        headers.reset(); + +        delete req;  		HttpRequest::destroyService();  		throw;  	} @@ -2367,8 +2304,8 @@ void HttpRequestTestObjectType::test<19>()  	mHandlerCalls = 0;  	HttpRequest * req = NULL; -	HttpOptions * options = NULL; -	HttpHeaders * headers = NULL; +	HttpOptions::ptr_t options; +	HttpHeaders::ptr_t headers;  	try  	{ @@ -2383,11 +2320,11 @@ void HttpRequestTestObjectType::test<19>()  		req = new HttpRequest();  		// options set -		options = new HttpOptions(); +        options = HttpOptions::ptr_t(new HttpOptions());  		options->setWantHeaders(true);  		// headers -		headers = new HttpHeaders; +		headers = HttpHeaders::ptr_t(new HttpHeaders);  		headers->append("Keep-Alive", "120");  		headers->append("Accept-encoding", "deflate");  		headers->append("Accept", "text/plain"); @@ -2502,17 +2439,8 @@ void HttpRequestTestObjectType::test<19>()  		ensure("Thread actually stopped running", HttpService::isStopped());  		// release options & headers -		if (options) -		{ -			options->release(); -		} -		options = NULL; - -		if (headers) -		{ -			headers->release(); -		} -		headers = NULL; +        options.reset(); +        headers.reset();  		// release the request object  		delete req; @@ -2524,16 +2452,9 @@ void HttpRequestTestObjectType::test<19>()  	catch (...)  	{  		stop_thread(req); -		if (options) -		{ -			options->release(); -			options = NULL; -		} -		if (headers) -		{ -			headers->release(); -			headers = NULL; -		} +        options.reset(); +        headers.reset(); +  		delete req;  		HttpRequest::destroyService();  		throw; @@ -2565,8 +2486,8 @@ void HttpRequestTestObjectType::test<20>()  	mHandlerCalls = 0;  	HttpRequest * req = NULL; -	HttpOptions * options = NULL; -	HttpHeaders * headers = NULL; +	HttpOptions::ptr_t options; +	HttpHeaders::ptr_t headers;  	BufferArray * ba = NULL;  	try @@ -2582,11 +2503,11 @@ void HttpRequestTestObjectType::test<20>()  		req = new HttpRequest();  		// options set -		options = new HttpOptions(); +        options = HttpOptions::ptr_t(new HttpOptions());  		options->setWantHeaders(true);  		// headers -		headers = new HttpHeaders(); +		headers = HttpHeaders::ptr_t(new HttpHeaders());  		headers->append("keep-Alive", "120");  		headers->append("Accept", "text/html");  		headers->append("content-type", "application/llsd+xml"); @@ -2720,17 +2641,8 @@ void HttpRequestTestObjectType::test<20>()  		ensure("Thread actually stopped running", HttpService::isStopped());  		// release options & headers -		if (options) -		{ -			options->release(); -		} -		options = NULL; - -		if (headers) -		{ -			headers->release(); -		} -		headers = NULL; +        options.reset(); +        headers.reset();  		// release the request object  		delete req; @@ -2747,16 +2659,8 @@ void HttpRequestTestObjectType::test<20>()  			ba->release();  			ba = NULL;  		} -		if (options) -		{ -			options->release(); -			options = NULL; -		} -		if (headers) -		{ -			headers->release(); -			headers = NULL; -		} +        options.reset(); +        headers.reset();  		delete req;  		HttpRequest::destroyService();  		throw; @@ -2788,8 +2692,8 @@ void HttpRequestTestObjectType::test<21>()  	mHandlerCalls = 0;  	HttpRequest * req = NULL; -	HttpOptions * options = NULL; -	HttpHeaders * headers = NULL; +	HttpOptions::ptr_t options; +	HttpHeaders::ptr_t headers;  	BufferArray * ba = NULL;  	try @@ -2805,11 +2709,11 @@ void HttpRequestTestObjectType::test<21>()  		req = new HttpRequest();  		// options set -		options = new HttpOptions(); +        options = HttpOptions::ptr_t(new HttpOptions());  		options->setWantHeaders(true);  		// headers -		headers = new HttpHeaders; +		headers = HttpHeaders::ptr_t(new HttpHeaders);  		headers->append("content-type", "text/plain");  		headers->append("content-type", "text/html");  		headers->append("content-type", "application/llsd+xml"); @@ -2937,17 +2841,8 @@ void HttpRequestTestObjectType::test<21>()  		ensure("Thread actually stopped running", HttpService::isStopped());  		// release options & headers -		if (options) -		{ -			options->release(); -		} -		options = NULL; - -		if (headers) -		{ -			headers->release(); -		} -		headers = NULL; +        options.reset(); +        headers.reset();  		// release the request object  		delete req; @@ -2964,16 +2859,8 @@ void HttpRequestTestObjectType::test<21>()  			ba->release();  			ba = NULL;  		} -		if (options) -		{ -			options->release(); -			options = NULL; -		} -		if (headers) -		{ -			headers->release(); -			headers = NULL; -		} +        options.reset(); +        headers.reset();  		delete req;  		HttpRequest::destroyService();  		throw; @@ -3000,13 +2887,13 @@ void HttpRequestTestObjectType::test<22>()  	mMemTotal = GetMemTotal();  	mHandlerCalls = 0; -	HttpOptions * options = NULL; +	HttpOptions::ptr_t options;  	HttpRequest * req = NULL;  	try  	{  		// options set -		options = new HttpOptions(); +        options = HttpOptions::ptr_t(new HttpOptions());  		options->setRetries(1);			// Partial_File is retryable and can timeout in here  		// Get singletons created @@ -3035,8 +2922,8 @@ void HttpRequestTestObjectType::test<22>()  														 0,  														 25,  														 options, -														 NULL, -														 &handler); +                                                         HttpHeaders::ptr_t(), +                                                         &handler);  			ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID);  		} @@ -3067,7 +2954,7 @@ void HttpRequestTestObjectType::test<22>()  														 0,  														 25,  														 options, -														 NULL, +														 HttpHeaders::ptr_t(),  														 &handler);  			ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID);  		} @@ -3099,8 +2986,8 @@ void HttpRequestTestObjectType::test<22>()  														 0,  														 25,  														 options, -														 NULL, -														 &handler); +                                                         HttpHeaders::ptr_t(), +                                                         &handler);  			ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID);  		} @@ -3144,11 +3031,7 @@ void HttpRequestTestObjectType::test<22>()  		ensure("Thread actually stopped running", HttpService::isStopped());  		// release options -		if (options) -		{ -			options->release(); -			options = NULL; -		} +        options.reset();  		// release the request object  		delete req; @@ -3198,7 +3081,7 @@ void HttpRequestTestObjectType::test<23>()  	mHandlerCalls = 0;  	HttpRequest * req = NULL; -	HttpOptions * opts = NULL; +	HttpOptions::ptr_t opts;  	try  	{ @@ -3213,7 +3096,7 @@ void HttpRequestTestObjectType::test<23>()  		req = new HttpRequest();  		ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); -		opts = new HttpOptions(); +        opts = HttpOptions::ptr_t(new HttpOptions());  		opts->setRetries(1);			// Retry once only  		opts->setUseRetryAfter(true);	// Try to parse the retry-after header @@ -3230,8 +3113,8 @@ void HttpRequestTestObjectType::test<23>()  														 0,  														 0,  														 opts, -														 NULL, -														 &handler); +                                                         HttpHeaders::ptr_t(), +                                                         &handler);  			std::ostringstream testtag;  			testtag << "Valid handle returned for 503 request #" << i; @@ -3277,8 +3160,7 @@ void HttpRequestTestObjectType::test<23>()  		ensure("Thread actually stopped running", HttpService::isStopped());  		// release options -		opts->release(); -		opts = NULL; +        opts.reset();  		// release the request object  		delete req; @@ -3299,11 +3181,7 @@ void HttpRequestTestObjectType::test<23>()  	catch (...)  	{  		stop_thread(req); -		if (opts) -		{ -			opts->release(); -			opts = NULL; -		} +        opts.reset();  		delete req;  		HttpRequest::destroyService();  		throw; diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp index cb05c4ff03..4caf6dcd05 100755 --- a/indra/llcrashlogger/llcrashlogger.cpp +++ b/indra/llcrashlogger/llcrashlogger.cpp @@ -407,7 +407,7 @@ bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg  		updateApplication(llformat("%s, try %d...", msg.c_str(), i+1));          LLCoreHttpUtil::requestPostWithLLSD(httpRequest.get(), LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, -            host, data, httpOpts.get(), NULL, new LLCrashLoggerHandler); +            host, data, httpOpts, LLCore::HttpHeaders::ptr_t(), new LLCrashLoggerHandler);          while(!gBreak)  		{ diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index cd3c527241..05d74a45a2 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -102,8 +102,8 @@ HttpHandle requestPostWithLLSD(HttpRequest * request,      HttpRequest::priority_t priority,      const std::string & url,      const LLSD & body, -    HttpOptions * options, -    HttpHeaders * headers, +    const HttpOptions::ptr_t &options, +    const HttpHeaders::ptr_t &headers,      HttpHandler * handler)  {      HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -129,8 +129,8 @@ HttpHandle requestPutWithLLSD(HttpRequest * request,      HttpRequest::priority_t priority,      const std::string & url,      const LLSD & body, -    HttpOptions * options, -    HttpHeaders * headers, +    const HttpOptions::ptr_t &options, +    const HttpHeaders::ptr_t &headers,      HttpHandler * handler)  {      HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -155,8 +155,8 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request,      HttpRequest::priority_t priority,      const std::string & url,      const LLSD & body, -    HttpOptions * options, -    HttpHeaders * headers, +    const HttpOptions::ptr_t &options, +    const HttpHeaders::ptr_t &headers,      HttpHandler * handler)  {      HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -286,7 +286,7 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H      writeStatusCodes(status, response->getRequestURL(), httpresults);      LLSD httpHeaders = LLSD::emptyMap(); -    LLCore::HttpHeaders * hdrs = response->getHeaders(); +    LLCore::HttpHeaders::ptr_t hdrs = response->getHeaders();      if (hdrs)      { @@ -596,7 +596,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request,      }      saveState(hhandle, request, handler); -    LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); +    LLSD results = waitForEventOn(handler->getReplyPump());      cleanState();      return results; @@ -689,7 +689,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request,      // The HTTPCoroHandler does not self delete, so retrieval of a the contained       // pointer from the smart pointer is safe in this case.      LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, mPriority, url, rawbody.get(), -        options.get(), headers.get(), handler.get()); +        options, headers, handler.get());      if (hhandle == LLCORE_HTTP_HANDLE_INVALID)      { @@ -697,7 +697,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request,      }      saveState(hhandle, request, handler); -    LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); +    LLSD results = waitForEventOn(handler->getReplyPump());      cleanState();      //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; @@ -735,7 +735,7 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request,      }      saveState(hhandle, request, handler); -    LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); +    LLSD results = waitForEventOn(handler->getReplyPump());      cleanState();      //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL;      return results; @@ -782,7 +782,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request,      // The HTTPCoroHandler does not self delete, so retrieval of a the contained       // pointer from the smart pointer is safe in this case.      LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, mPriority, -        url, options.get(), headers.get(), handler.get()); +        url, options, headers, handler.get());      if (hhandle == LLCORE_HTTP_HANDLE_INVALID)      { @@ -790,7 +790,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request,      }      saveState(hhandle, request, handler); -    LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); +    LLSD results = waitForEventOn(handler->getReplyPump());      cleanState();      //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL;      return results; @@ -817,7 +817,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request,      // The HTTPCoroHandler does not self delete, so retrieval of a the contained       // pointer from the smart pointer is safe in this case.      LLCore::HttpHandle hhandle = request->requestDelete(mPolicyId, mPriority, -        url, options.get(), headers.get(), handler.get()); +        url, options, headers, handler.get());      if (hhandle == LLCORE_HTTP_HANDLE_INVALID)      { @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request,      }      saveState(hhandle, request, handler); -    LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); +    LLSD results = waitForEventOn(handler->getReplyPump());      cleanState();      //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL;      return results; diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index cf35177e48..999fd5f90b 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -107,25 +107,25 @@ std::string responseToString(LLCore::HttpResponse * response);  ///						a now-useless HttpHandler object.  ///  LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, -									   LLCore::HttpRequest::policy_t policy_id, -									   LLCore::HttpRequest::priority_t priority, -									   const std::string & url, -									   const LLSD & body, -									   LLCore::HttpOptions * options, -									   LLCore::HttpHeaders * headers, -									   LLCore::HttpHandler * handler); +    LLCore::HttpRequest::policy_t policy_id, +    LLCore::HttpRequest::priority_t priority, +    const std::string & url, +    const LLSD & body, +    const LLCore::HttpOptions::ptr_t &options, +    const LLCore::HttpHeaders::ptr_t &headers, +    LLCore::HttpHandler * handler);  inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request,  	LLCore::HttpRequest::policy_t policy_id,  	LLCore::HttpRequest::priority_t priority,  	const std::string & url,  	const LLSD & body, -	LLCore::HttpOptions::ptr_t & options, -	LLCore::HttpHeaders::ptr_t & headers, +	const LLCore::HttpOptions::ptr_t & options, +	const LLCore::HttpHeaders::ptr_t & headers,  	LLCore::HttpHandler * handler)  {      return requestPostWithLLSD(request.get(), policy_id, priority, -        url, body, options.get(), headers.get(), handler); +        url, body, options, headers, handler);  }  inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -135,8 +135,11 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque      const LLSD & body,      LLCore::HttpHandler * handler)  { +    LLCore::HttpOptions::ptr_t options; +    LLCore::HttpHeaders::ptr_t headers; +      return requestPostWithLLSD(request.get(), policy_id, priority, -        url, body, NULL, NULL, handler); +        url, body, options, headers, handler);  } @@ -161,8 +164,8 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request,  	LLCore::HttpRequest::priority_t priority,  	const std::string & url,  	const LLSD & body, -	LLCore::HttpOptions * options, -	LLCore::HttpHeaders * headers, +	const LLCore::HttpOptions::ptr_t &options, +	const LLCore::HttpHeaders::ptr_t &headers,  	LLCore::HttpHandler * handler);  inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -170,12 +173,12 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques  	LLCore::HttpRequest::priority_t priority,  	const std::string & url,  	const LLSD & body, -	LLCore::HttpOptions::ptr_t & options, -	LLCore::HttpHeaders::ptr_t & headers, +	const LLCore::HttpOptions::ptr_t & options, +	const LLCore::HttpHeaders::ptr_t & headers,  	LLCore::HttpHandler * handler)  {      return requestPutWithLLSD(request.get(), policy_id, priority, -        url, body, options.get(), headers.get(), handler); +        url, body, options, headers, handler);  }  inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -185,8 +188,11 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques      const LLSD & body,      LLCore::HttpHandler * handler)  { +    LLCore::HttpOptions::ptr_t options; +    LLCore::HttpHeaders::ptr_t headers; +      return requestPutWithLLSD(request.get(), policy_id, priority, -        url, body, NULL, NULL, handler); +        url, body, options, headers, handler);  }  /// Issue a standard HttpRequest::requestPatch() call but using @@ -210,8 +216,8 @@ LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request,      LLCore::HttpRequest::priority_t priority,      const std::string & url,      const LLSD & body, -    LLCore::HttpOptions * options, -    LLCore::HttpHeaders * headers, +    const LLCore::HttpOptions::ptr_t &options, +    const LLCore::HttpHeaders::ptr_t &headers,      LLCore::HttpHandler * handler);  inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -219,12 +225,12 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ      LLCore::HttpRequest::priority_t priority,      const std::string & url,      const LLSD & body, -    LLCore::HttpOptions::ptr_t & options, -    LLCore::HttpHeaders::ptr_t & headers, +    const LLCore::HttpOptions::ptr_t & options, +    const LLCore::HttpHeaders::ptr_t & headers,      LLCore::HttpHandler * handler)  {      return requestPatchWithLLSD(request.get(), policy_id, priority, -        url, body, options.get(), headers.get(), handler); +        url, body, options, headers, handler);  }  inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -234,8 +240,11 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ      const LLSD & body,      LLCore::HttpHandler * handler)  { +    LLCore::HttpOptions::ptr_t options; +    LLCore::HttpHeaders::ptr_t headers; +      return requestPatchWithLLSD(request.get(), policy_id, priority, -        url, body, NULL, NULL, handler); +        url, body, options, headers, handler);  }  //========================================================================= diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index e492b8cf5d..fe01288e23 100755 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -352,6 +352,7 @@ void LLAssetUploadResponder::uploadComplete(const LLSD& content)  {  } +#if 0  LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(  	const LLSD& post_data,  	const LLUUID& vfile_id, @@ -473,6 +474,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)  	//LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], TRUE);  } +#endif  LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(  	const LLSD& post_data, diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h index 18968bb1af..6828678f09 100755 --- a/indra/newview/llassetuploadresponders.h +++ b/indra/newview/llassetuploadresponders.h @@ -60,6 +60,7 @@ protected:  	std::string mFileName;  }; +#if 0  // TODO*: Remove this once deprecated  class LLNewAgentInventoryResponder : public LLAssetUploadResponder  { @@ -78,7 +79,7 @@ public:  protected:  	virtual void httpFailure();  }; - +#endif  #if 0  // A base class which goes through and performs some default  // actions for variable price uploads.  If more specific actions diff --git a/indra/newview/llcoproceduremanager.cpp b/indra/newview/llcoproceduremanager.cpp index d3168985f8..1a4a906f35 100644 --- a/indra/newview/llcoproceduremanager.cpp +++ b/indra/newview/llcoproceduremanager.cpp @@ -138,7 +138,7 @@ void LLCoprocedureManager::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineA      while (!mShutdown)      { -        llcoro::waitForEventOn(mWakeupTrigger); +        waitForEventOn(mWakeupTrigger);          if (mShutdown)              break; diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 0aad1d5ba9..54da226209 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -197,7 +197,7 @@ namespace Details                          " seconds, error count is now " << errorCount << LL_ENDL;                      timeout.eventAfter(waitToRetry, LLSD()); -                    llcoro::waitForEventOn(timeout); +                    waitForEventOn(timeout);                      if (mDone)                          break; diff --git a/indra/newview/llhttpretrypolicy.cpp b/indra/newview/llhttpretrypolicy.cpp index 530eb685fa..e2e151eb63 100755 --- a/indra/newview/llhttpretrypolicy.cpp +++ b/indra/newview/llhttpretrypolicy.cpp @@ -56,7 +56,7 @@ bool LLAdaptiveRetryPolicy::getRetryAfter(const LLSD& headers, F32& retry_header  			&& getSecondsUntilRetryAfter(headers[HTTP_IN_HEADER_RETRY_AFTER].asStringRef(), retry_header_time));  } -bool LLAdaptiveRetryPolicy::getRetryAfter(const LLCore::HttpHeaders *headers, F32& retry_header_time) +bool LLAdaptiveRetryPolicy::getRetryAfter(const LLCore::HttpHeaders::ptr_t &headers, F32& retry_header_time)  {  	if (headers)  	{ @@ -85,7 +85,7 @@ void LLAdaptiveRetryPolicy::onFailure(S32 status, const LLSD& headers)  void LLAdaptiveRetryPolicy::onFailure(const LLCore::HttpResponse *response)  {  	F32 retry_header_time; -	const LLCore::HttpHeaders *headers = response->getHeaders(); +	const LLCore::HttpHeaders::ptr_t headers = response->getHeaders();  	bool has_retry_header_time = getRetryAfter(headers,retry_header_time);  	onFailureCommon(response->getStatus().getType(), has_retry_header_time, retry_header_time);  } diff --git a/indra/newview/llhttpretrypolicy.h b/indra/newview/llhttpretrypolicy.h index cf79e0b401..c0cc263546 100755 --- a/indra/newview/llhttpretrypolicy.h +++ b/indra/newview/llhttpretrypolicy.h @@ -79,7 +79,7 @@ public:  protected:  	void init();  	bool getRetryAfter(const LLSD& headers, F32& retry_header_time); -	bool getRetryAfter(const LLCore::HttpHeaders *headers, F32& retry_header_time); +	bool getRetryAfter(const LLCore::HttpHeaders::ptr_t &headers, F32& retry_header_time);  	void onFailureCommon(S32 status, bool has_retry_header_time, F32 retry_header_time);  private: diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 25450f2317..47d3e88b3a 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -148,8 +148,8 @@ LLInventoryModel::LLInventoryModel()  	mObservers(),  	mHttpRequestFG(NULL),  	mHttpRequestBG(NULL), -	mHttpOptions(NULL), -	mHttpHeaders(NULL), +	mHttpOptions(), +	mHttpHeaders(),  	mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID),  	mHttpPriorityFG(0),  	mHttpPriorityBG(0), @@ -178,16 +178,9 @@ void LLInventoryModel::cleanupInventory()  	mObservers.clear();  	// Run down HTTP transport -	if (mHttpHeaders) -	{ -		mHttpHeaders->release(); -		mHttpHeaders = NULL; -	} -	if (mHttpOptions) -	{ -		mHttpOptions->release(); -		mHttpOptions = NULL; -	} +    mHttpHeaders.reset(); +    mHttpOptions.reset(); +  	delete mHttpRequestFG;  	mHttpRequestFG = NULL;  	delete mHttpRequestBG; @@ -613,7 +606,7 @@ void LLInventoryModel::createNewCategoryCoro(std::string url, LLSD postData, inv      LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t          httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("createNewCategoryCoro", httpPolicy));      LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); -    LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); +    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);      httpOpts->setWantHeaders(true); @@ -2418,11 +2411,11 @@ void LLInventoryModel::initHttpRequest()  		mHttpRequestFG = new LLCore::HttpRequest;  		mHttpRequestBG = new LLCore::HttpRequest; -		mHttpOptions = new LLCore::HttpOptions; +		mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);  		mHttpOptions->setTransferTimeout(300);  		mHttpOptions->setUseRetryAfter(true);  		// mHttpOptions->setTrace(2);		// Do tracing of requests -		mHttpHeaders = new LLCore::HttpHeaders; +        mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);  		mHttpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML);  		mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_LLSD_XML);  		mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_INVENTORY); diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 1f1c686ef1..e8977bc7d7 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -571,8 +571,8 @@ private:  	// Usual plumbing for LLCore:: HTTP operations.  	LLCore::HttpRequest *				mHttpRequestFG;  	LLCore::HttpRequest *				mHttpRequestBG; -	LLCore::HttpOptions *				mHttpOptions; -	LLCore::HttpHeaders *				mHttpHeaders; +	LLCore::HttpOptions::ptr_t			mHttpOptions; +	LLCore::HttpHeaders::ptr_t			mHttpHeaders;  	LLCore::HttpRequest::policy_t		mHttpPolicyClass;  	LLCore::HttpRequest::priority_t		mHttpPriorityFG;  	LLCore::HttpRequest::priority_t		mHttpPriorityBG; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index aef5bcf0dd..1045def72e 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -712,7 +712,7 @@ void LLMaterialMgr::processGetAllQueue()  			);  		LLCore::HttpHandle handle = mHttpRequest->requestGet(mHttpPolicy, mHttpPriority, capURL, -				mHttpOptions.get(), mHttpHeaders.get(), handler); +				mHttpOptions, mHttpHeaders, handler);  		if (handle == LLCORE_HTTP_HANDLE_INVALID)  		{ diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 648056484e..d6aaf18cb7 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -738,9 +738,9 @@ void log_upload_error(LLCore::HttpStatus status, const LLSD& content,  LLMeshRepoThread::LLMeshRepoThread()  : LLThread("mesh repo"),    mHttpRequest(NULL), -  mHttpOptions(NULL), -  mHttpLargeOptions(NULL), -  mHttpHeaders(NULL), +  mHttpOptions(), +  mHttpLargeOptions(), +  mHttpHeaders(),    mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID),    mHttpLegacyPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID),    mHttpLargePolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), @@ -753,13 +753,13 @@ LLMeshRepoThread::LLMeshRepoThread()  	mHeaderMutex = new LLMutex(NULL);  	mSignal = new LLCondition(NULL);  	mHttpRequest = new LLCore::HttpRequest; -	mHttpOptions = new LLCore::HttpOptions; +	mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);  	mHttpOptions->setTransferTimeout(SMALL_MESH_XFER_TIMEOUT);  	mHttpOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter")); -	mHttpLargeOptions = new LLCore::HttpOptions; +	mHttpLargeOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);  	mHttpLargeOptions->setTransferTimeout(LARGE_MESH_XFER_TIMEOUT);  	mHttpLargeOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter")); -	mHttpHeaders = new LLCore::HttpHeaders; +	mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);  	mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_VND_LL_MESH);  	mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_MESH2);  	mHttpLegacyPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_MESH1); @@ -781,22 +781,9 @@ LLMeshRepoThread::~LLMeshRepoThread()  		delete *iter;  	}  	mHttpRequestSet.clear(); -	if (mHttpHeaders) -	{ -		mHttpHeaders->release(); -		mHttpHeaders = NULL; -	} -	if (mHttpOptions) -	{ -		mHttpOptions->release(); -		mHttpOptions = NULL; -	} -	if (mHttpLargeOptions) -	{ -		mHttpLargeOptions->release(); -		mHttpLargeOptions = NULL; -	} -	delete mHttpRequest; +    mHttpHeaders.reset(); + +    delete mHttpRequest;  	mHttpRequest = NULL;  	delete mMutex;  	mMutex = NULL; @@ -1882,11 +1869,11 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data,  	mMeshUploadTimeOut = gSavedSettings.getS32("MeshUploadTimeOut") ;  	mHttpRequest = new LLCore::HttpRequest; -	mHttpOptions = new LLCore::HttpOptions; +	mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);  	mHttpOptions->setTransferTimeout(mMeshUploadTimeOut);  	mHttpOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter"));  	mHttpOptions->setRetries(UPLOAD_RETRY_LIMIT); -	mHttpHeaders = new LLCore::HttpHeaders; +	mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);  	mHttpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML);  	mHttpPolicyClass = LLAppViewer::instance()->getAppCoreHttp().getPolicy(LLAppCoreHttp::AP_UPLOADS);  	mHttpPriority = 0; @@ -1894,16 +1881,6 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data,  LLMeshUploadThread::~LLMeshUploadThread()  { -	if (mHttpHeaders) -	{ -		mHttpHeaders->release(); -		mHttpHeaders = NULL; -	} -	if (mHttpOptions) -	{ -		mHttpOptions->release(); -		mHttpOptions = NULL; -	}  	delete mHttpRequest;  	mHttpRequest = NULL;  } diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 39280bea3a..55157cc040 100755 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -322,9 +322,9 @@ public:  	// llcorehttp library interface objects.  	LLCore::HttpStatus					mHttpStatus;  	LLCore::HttpRequest *				mHttpRequest; -	LLCore::HttpOptions *				mHttpOptions; -	LLCore::HttpOptions *				mHttpLargeOptions; -	LLCore::HttpHeaders *				mHttpHeaders; +	LLCore::HttpOptions::ptr_t			mHttpOptions; +	LLCore::HttpOptions::ptr_t			mHttpLargeOptions; +	LLCore::HttpHeaders::ptr_t			mHttpHeaders;  	LLCore::HttpRequest::policy_t		mHttpPolicyClass;  	LLCore::HttpRequest::policy_t		mHttpLegacyPolicyClass;  	LLCore::HttpRequest::policy_t		mHttpLargePolicyClass; @@ -493,8 +493,8 @@ private:  	// llcorehttp library interface objects.  	LLCore::HttpStatus					mHttpStatus;  	LLCore::HttpRequest *				mHttpRequest; -	LLCore::HttpOptions *				mHttpOptions; -	LLCore::HttpHeaders *				mHttpHeaders; +	LLCore::HttpOptions::ptr_t			mHttpOptions; +	LLCore::HttpHeaders::ptr_t			mHttpHeaders;  	LLCore::HttpRequest::policy_t		mHttpPolicyClass;  	LLCore::HttpRequest::priority_t		mHttpPriority;  }; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index f4b1ff7313..e61eeb2f4e 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -1557,7 +1557,7 @@ bool LLTextureFetchWorker::doWork(S32 param)  		// Will call callbackHttpGet when curl request completes  		// Only server bake images use the returned headers currently, for getting retry-after field. -		LLCore::HttpOptions *options = (mFTType == FTT_SERVER_BAKE) ? mFetcher->mHttpOptionsWithHeaders: mFetcher->mHttpOptions; +		LLCore::HttpOptions::ptr_t options = (mFTType == FTT_SERVER_BAKE) ? mFetcher->mHttpOptionsWithHeaders: mFetcher->mHttpOptions;  		if (disable_range_req)  		{  			// 'Range:' requests may be disabled in which case all HTTP @@ -2509,11 +2509,11 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image  	  mTotalHTTPRequests(0),  	  mQAMode(qa_mode),  	  mHttpRequest(NULL), -	  mHttpOptions(NULL), -	  mHttpOptionsWithHeaders(NULL), -	  mHttpHeaders(NULL), +	  mHttpOptions(), +	  mHttpOptionsWithHeaders(), +	  mHttpHeaders(),  	  mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), -	  mHttpMetricsHeaders(NULL), +	  mHttpMetricsHeaders(),  	  mHttpMetricsPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID),  	  mTotalCacheReadCount(0U),  	  mTotalCacheWriteCount(0U), @@ -2528,13 +2528,13 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image  	LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp());  	mHttpRequest = new LLCore::HttpRequest; -	mHttpOptions = new LLCore::HttpOptions; -	mHttpOptionsWithHeaders = new LLCore::HttpOptions; +	mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); +	mHttpOptionsWithHeaders = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);  	mHttpOptionsWithHeaders->setWantHeaders(true); -	mHttpHeaders = new LLCore::HttpHeaders; +    mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);  	mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C);  	mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_TEXTURE); -	mHttpMetricsHeaders = new LLCore::HttpHeaders; +    mHttpMetricsHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);  	mHttpMetricsHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML);  	mHttpMetricsPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_REPORTING);  	mHttpHighWater = HTTP_NONPIPE_REQUESTS_HIGH_WATER; @@ -2568,30 +2568,6 @@ LLTextureFetch::~LLTextureFetch()  		delete req;  	} -	if (mHttpOptions) -	{ -		mHttpOptions->release(); -		mHttpOptions = NULL; -	} - -	if (mHttpOptionsWithHeaders) -	{ -		mHttpOptionsWithHeaders->release(); -		mHttpOptionsWithHeaders = NULL; -	} - -	if (mHttpHeaders) -	{ -		mHttpHeaders->release(); -		mHttpHeaders = NULL; -	} - -	if (mHttpMetricsHeaders) -	{ -		mHttpMetricsHeaders->release(); -		mHttpMetricsHeaders = NULL; -	} -  	mHttpWaitResource.clear();  	delete mHttpRequest; @@ -4043,7 +4019,7 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)  											report_priority,  											mCapsURL,  											sd, -											NULL, +											LLCore::HttpOptions::ptr_t(),  											fetcher->getMetricsHeaders(),  											handler);  		LLTextureFetch::svMetricsDataBreak = false; @@ -4162,7 +4138,7 @@ LLTextureFetchDebugger::LLTextureFetchDebugger(LLTextureFetch* fetcher, LLTextur  	mFetcher(fetcher),  	mTextureCache(cache),  	mImageDecodeThread(imagedecodethread), -	mHttpHeaders(NULL), +	mHttpHeaders(),  	mHttpPolicyClass(fetcher->getPolicyClass()),  	mNbCurlCompleted(0),  	mTempIndex(0), @@ -4176,11 +4152,6 @@ LLTextureFetchDebugger::~LLTextureFetchDebugger()  	mFetchingHistory.clear();  	mStopDebug = TRUE;  	tryToStopDebug(); -	if (mHttpHeaders) -	{ -		mHttpHeaders->release(); -		mHttpHeaders = NULL; -	}  }  void LLTextureFetchDebugger::init() @@ -4225,7 +4196,7 @@ void LLTextureFetchDebugger::init()  	if (! mHttpHeaders)  	{ -		mHttpHeaders = new LLCore::HttpHeaders; +        mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);  		mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C);  	}  } @@ -4625,7 +4596,7 @@ S32 LLTextureFetchDebugger::fillCurlQueue()  																				   texture_url,  																				   0,  																				   requestedSize, -																				   NULL, +																				   LLCore::HttpOptions::ptr_t(),  																				   mHttpHeaders,  																				   this);  		if (LLCORE_HTTP_HANDLE_INVALID != handle) diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index 27779a31e0..e569175e8f 100755 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -177,7 +177,7 @@ public:  	// to do that to hold a reference for any length of time.  	//  	// Threads:  T* -	LLCore::HttpHeaders * getMetricsHeaders() const	{ return mHttpMetricsHeaders; } +	LLCore::HttpHeaders::ptr_t getMetricsHeaders() const	{ return mHttpMetricsHeaders; }  	// Threads:  T*  	LLCore::HttpRequest::policy_t getMetricsPolicyClass() const { return mHttpMetricsPolicyClass; } @@ -354,11 +354,11 @@ private:  	// to make our HTTP requests.  These replace the various  	// LLCurl interfaces used in the past.  	LLCore::HttpRequest *				mHttpRequest;					// Ttf -	LLCore::HttpOptions *				mHttpOptions;					// Ttf -	LLCore::HttpOptions *				mHttpOptionsWithHeaders;		// Ttf -	LLCore::HttpHeaders *				mHttpHeaders;					// Ttf +	LLCore::HttpOptions::ptr_t			mHttpOptions;					// Ttf +	LLCore::HttpOptions::ptr_t			mHttpOptionsWithHeaders;		// Ttf +	LLCore::HttpHeaders::ptr_t			mHttpHeaders;					// Ttf  	LLCore::HttpRequest::policy_t		mHttpPolicyClass;				// T* -	LLCore::HttpHeaders *				mHttpMetricsHeaders;			// Ttf +	LLCore::HttpHeaders::ptr_t			mHttpMetricsHeaders;			// Ttf  	LLCore::HttpRequest::policy_t		mHttpMetricsPolicyClass;		// T*  	S32									mHttpHighWater;					// Ttf  	S32									mHttpLowWater;					// Ttf @@ -510,7 +510,7 @@ private:  	LLTextureFetch* mFetcher;  	LLTextureCache* mTextureCache;  	LLImageDecodeThread* mImageDecodeThread; -	LLCore::HttpHeaders* mHttpHeaders; +	LLCore::HttpHeaders::ptr_t mHttpHeaders;  	LLCore::HttpRequest::policy_t mHttpPolicyClass;  	S32 mNumFetchedTextures; diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 717b14bb72..51001a51d2 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -28,7 +28,6 @@  #include "llviewerprecompiledheaders.h"  #include "linden_common.h" -#include "llviewerassetupload.h"  #include "llviewertexturelist.h"  #include "llimage.h"  #include "lltrans.h" @@ -43,6 +42,359 @@  #include "llstatusbar.h"  #include "llinventorypanel.h"  #include "llsdutil.h" +#include "llviewerassetupload.h" +#include "llappviewer.h" +#include "llviewerstats.h" +#include "llvfile.h" + +LLSD NewResourceUploadInfo::prepareUpload() +{ +    if (mAssetId.isNull()) +        generateNewAssetId(); + +    incrementUploadStats(); +    assignDefaults(); + +    return LLSD().with("success", LLSD::Boolean(true)); +} + +std::string NewResourceUploadInfo::getAssetTypeString() const +{ +    return LLAssetType::lookup(mAssetType); +} + +std::string NewResourceUploadInfo::getInventoryTypeString() const +{ +    return LLInventoryType::lookup(mInventoryType); +} + +LLSD NewResourceUploadInfo::generatePostBody() +{ +    LLSD body; + +    body["folder_id"] = mFolderId; +    body["asset_type"] = getAssetTypeString(); +    body["inventory_type"] = getInventoryTypeString(); +    body["name"] = mName; +    body["description"] = mDescription; +    body["next_owner_mask"] = LLSD::Integer(mNextOwnerPerms); +    body["group_mask"] = LLSD::Integer(mGroupPerms); +    body["everyone_mask"] = LLSD::Integer(mEveryonePerms); + +    return body; + +} + +void NewResourceUploadInfo::logPreparedUpload() +{ +    LL_INFOS() << "*** Uploading: " << std::endl << +        "Type: " << LLAssetType::lookup(mAssetType) << std::endl << +        "UUID: " << mAssetId.asString() << std::endl << +        "Name: " << mName << std::endl << +        "Desc: " << mDescription << std::endl << +        "Expected Upload Cost: " << mExpectedUploadCost << std::endl << +        "Folder: " << mFolderId << std::endl << +        "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL; +} + +LLUUID NewResourceUploadInfo::finishUpload(LLSD &result) +{ +    if (getFolderId().isNull()) +    { +        return LLUUID::null; +    } + +    U32 permsEveryone = PERM_NONE; +    U32 permsGroup = PERM_NONE; +    U32 permsNextOwner = PERM_ALL; + +    if (result.has("new_next_owner_mask")) +    { +        // The server provided creation perms so use them. +        // Do not assume we got the perms we asked for in +        // since the server may not have granted them all. +        permsEveryone = result["new_everyone_mask"].asInteger(); +        permsGroup = result["new_group_mask"].asInteger(); +        permsNextOwner = result["new_next_owner_mask"].asInteger(); +    } +    else +    { +        // The server doesn't provide creation perms +        // so use old assumption-based perms. +        if (getAssetTypeString() != "snapshot") +        { +            permsNextOwner = PERM_MOVE | PERM_TRANSFER; +        } +    } + +    LLPermissions new_perms; +    new_perms.init( +        gAgent.getID(), +        gAgent.getID(), +        LLUUID::null, +        LLUUID::null); + +    new_perms.initMasks( +        PERM_ALL, +        PERM_ALL, +        permsEveryone, +        permsGroup, +        permsNextOwner); + +    U32 flagsInventoryItem = 0; +    if (result.has("inventory_flags")) +    { +        flagsInventoryItem = static_cast<U32>(result["inventory_flags"].asInteger()); +        if (flagsInventoryItem != 0) +        { +            LL_INFOS() << "inventory_item_flags " << flagsInventoryItem << LL_ENDL; +        } +    } +    S32 creationDate = time_corrected(); + +    LLUUID serverInventoryItem = result["new_inventory_item"].asUUID(); +    LLUUID serverAssetId = result["new_asset"].asUUID(); + +    LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem( +        serverInventoryItem, +        getFolderId(), +        new_perms, +        serverAssetId, +        getAssetType(), +        getInventoryType(), +        getName(), +        getDescription(), +        LLSaleInfo::DEFAULT, +        flagsInventoryItem, +        creationDate); + +    gInventory.updateItem(item); +    gInventory.notifyObservers(); + +    return serverInventoryItem; +} + + +LLAssetID NewResourceUploadInfo::generateNewAssetId() +{ +    if (gDisconnected) +    { +        LLAssetID rv; + +        rv.setNull(); +        return rv; +    } +    mAssetId = mTransactionId.makeAssetID(gAgent.getSecureSessionID()); + +    return mAssetId; +} + +void NewResourceUploadInfo::incrementUploadStats() const +{ +    if (LLAssetType::AT_SOUND == mAssetType) +    { +        add(LLStatViewer::UPLOAD_SOUND, 1); +    } +    else if (LLAssetType::AT_TEXTURE == mAssetType) +    { +        add(LLStatViewer::UPLOAD_TEXTURE, 1); +    } +    else if (LLAssetType::AT_ANIMATION == mAssetType) +    { +        add(LLStatViewer::ANIMATION_UPLOADS, 1); +    } +} + +void NewResourceUploadInfo::assignDefaults() +{ +    if (LLInventoryType::IT_NONE == mInventoryType) +    { +        mInventoryType = LLInventoryType::defaultForAssetType(mAssetType); +    } +    LLStringUtil::stripNonprintable(mName); +    LLStringUtil::stripNonprintable(mDescription); + +    if (mName.empty()) +    { +        mName = "(No Name)"; +    } +    if (mDescription.empty()) +    { +        mDescription = "(No Description)"; +    } + +    mFolderId = gInventory.findCategoryUUIDForType( +        (mDestinationFolderType == LLFolderType::FT_NONE) ? +        (LLFolderType::EType)mAssetType : mDestinationFolderType); + +} + +std::string NewResourceUploadInfo::getDisplayName() const +{ +    return (mName.empty()) ? mAssetId.asString() : mName; +}; + +//========================================================================= +NewFileResourceUploadInfo::NewFileResourceUploadInfo( +    std::string fileName, +    std::string name, +    std::string description, +    S32 compressionInfo, +    LLFolderType::EType destinationType, +    LLInventoryType::EType inventoryType, +    U32 nextOWnerPerms, +    U32 groupPerms, +    U32 everyonePerms, +    S32 expectedCost) : +    NewResourceUploadInfo(name, description, compressionInfo, +    destinationType, inventoryType, +    nextOWnerPerms, groupPerms, everyonePerms, expectedCost), +    mFileName(fileName) +{ +    LLTransactionID tid; +    tid.generate(); +    setTransactionId(tid); +} + + + +LLSD NewFileResourceUploadInfo::prepareUpload() +{ +    generateNewAssetId(); + +    LLSD result = exportTempFile(); +    if (result.has("error")) +        return result; + +    return NewResourceUploadInfo::prepareUpload(); +} + +LLSD NewFileResourceUploadInfo::exportTempFile() +{ +    std::string filename = gDirUtilp->getTempFilename(); + +    std::string exten = gDirUtilp->getExtension(getFileName()); +    U32 codec = LLImageBase::getCodecFromExtension(exten); + +    LLAssetType::EType assetType = LLAssetType::AT_NONE; +    std::string errorMessage; +    std::string errorLabel; + +    bool error = false; + +    if (exten.empty()) +    { +        std::string shortName = gDirUtilp->getBaseFileName(filename); + +        // No extension +        errorMessage = llformat( +            "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", +            shortName.c_str()); +        errorLabel = "NoFileExtension"; +        error = true; +    } +    else if (codec != IMG_CODEC_INVALID) +    { +        // It's an image file, the upload procedure is the same for all +        assetType = LLAssetType::AT_TEXTURE; +        if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec)) +        { +            errorMessage = llformat("Problem with file %s:\n\n%s\n", +                getFileName().c_str(), LLImage::getLastError().c_str()); +            errorLabel = "ProblemWithFile"; +            error = true; +        } +    } +    else if (exten == "wav") +    { +        assetType = LLAssetType::AT_SOUND;  // tag it as audio +        S32 encodeResult = 0; + +        LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL; + +        encodeResult = encode_vorbis_file(getFileName(), filename); + +        if (LLVORBISENC_NOERR != encodeResult) +        { +            switch (encodeResult) +            { +            case LLVORBISENC_DEST_OPEN_ERR: +                errorMessage = llformat("Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); +                errorLabel = "CannotOpenTemporarySoundFile"; +                break; + +            default: +                errorMessage = llformat("Unknown vorbis encode failure on: %s\n", getFileName().c_str()); +                errorLabel = "UnknownVorbisEncodeFailure"; +                break; +            } +            error = true; +        } +    } +    else if (exten == "bvh") +    { +        errorMessage = llformat("We do not currently support bulk upload of animation files\n"); +        errorLabel = "DoNotSupportBulkAnimationUpload"; +        error = true; +    } +    else if (exten == "anim") +    { +        assetType = LLAssetType::AT_ANIMATION; +        filename = getFileName(); +    } +    else +    { +        // Unknown extension +        errorMessage = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str()); +        errorLabel = "ErrorMessage"; +        error = TRUE;; +    } + +    if (error) +    { +        LLSD errorResult(LLSD::emptyMap()); + +        errorResult["error"] = LLSD::Binary(true); +        errorResult["message"] = errorMessage; +        errorResult["label"] = errorLabel; +        return errorResult; +    } + +    setAssetType(assetType); + +    // copy this file into the vfs for upload +    S32 file_size; +    LLAPRFile infile; +    infile.open(filename, LL_APR_RB, NULL, &file_size); +    if (infile.getFileHandle()) +    { +        LLVFile file(gVFS, getAssetId(), assetType, LLVFile::WRITE); + +        file.setMaxSize(file_size); + +        const S32 buf_size = 65536; +        U8 copy_buf[buf_size]; +        while ((file_size = infile.read(copy_buf, buf_size))) +        { +            file.write(copy_buf, file_size); +        } +    } +    else +    { +        errorMessage = llformat("Unable to access output file: %s", filename.c_str()); +        LLSD errorResult(LLSD::emptyMap()); + +        errorResult["error"] = LLSD::Binary(true); +        errorResult["message"] = errorMessage; +        return errorResult; +    } + +    return LLSD(); + +} + +//========================================================================= +  //=========================================================================  /*static*/ @@ -203,3 +555,4 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res      }  } + diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 38167fc0c7..119a5bc3e8 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -35,7 +35,160 @@  #include "llcoros.h"  #include "llcorehttputil.h" -#include "llviewermenufile.h" +class NewResourceUploadInfo +{ +public: +    typedef boost::shared_ptr<NewResourceUploadInfo> ptr_t; + +    NewResourceUploadInfo( +            LLTransactionID transactId, +            LLAssetType::EType assetType, +            std::string name, +            std::string description, +            S32 compressionInfo, +            LLFolderType::EType destinationType, +            LLInventoryType::EType inventoryType, +            U32 nextOWnerPerms, +            U32 groupPerms, +            U32 everyonePerms, +            S32 expectedCost) : +        mTransactionId(transactId), +        mAssetType(assetType), +        mName(name), +        mDescription(description), +        mCompressionInfo(compressionInfo), +        mDestinationFolderType(destinationType), +        mInventoryType(inventoryType), +        mNextOwnerPerms(nextOWnerPerms), +        mGroupPerms(groupPerms), +        mEveryonePerms(everyonePerms), +        mExpectedUploadCost(expectedCost), +        mFolderId(LLUUID::null), +        mItemId(LLUUID::null), +        mAssetId(LLAssetID::null) +    { } + +    virtual ~NewResourceUploadInfo() +    { } + +    virtual LLSD        prepareUpload(); +    virtual LLSD        generatePostBody(); +    virtual void        logPreparedUpload(); +    virtual LLUUID      finishUpload(LLSD &result); + +    LLTransactionID     getTransactionId() const { return mTransactionId; } +    LLAssetType::EType  getAssetType() const { return mAssetType; } +    std::string         getAssetTypeString() const; +    std::string         getName() const { return mName; }; +    std::string         getDescription() const { return mDescription; }; +    S32                 getCompressionInfo() const { return mCompressionInfo; }; +    LLFolderType::EType getDestinationFolderType() const { return mDestinationFolderType; }; +    LLInventoryType::EType  getInventoryType() const { return mInventoryType; }; +    std::string         getInventoryTypeString() const; +    U32                 getNextOwnerPerms() const { return mNextOwnerPerms; }; +    U32                 getGroupPerms() const { return mGroupPerms; }; +    U32                 getEveryonePerms() const { return mEveryonePerms; }; +    S32                 getExpectedUploadCost() const { return mExpectedUploadCost; }; + +    virtual std::string getDisplayName() const; + +    LLUUID              getFolderId() const { return mFolderId; } +    LLUUID              getItemId() const { return mItemId; } +    LLAssetID           getAssetId() const { return mAssetId; } + +protected: +    NewResourceUploadInfo( +            std::string name, +            std::string description, +            S32 compressionInfo, +            LLFolderType::EType destinationType, +            LLInventoryType::EType inventoryType, +            U32 nextOWnerPerms, +            U32 groupPerms, +            U32 everyonePerms, +            S32 expectedCost) : +        mName(name), +        mDescription(description), +        mCompressionInfo(compressionInfo), +        mDestinationFolderType(destinationType), +        mInventoryType(inventoryType), +        mNextOwnerPerms(nextOWnerPerms), +        mGroupPerms(groupPerms), +        mEveryonePerms(everyonePerms), +        mExpectedUploadCost(expectedCost), +        mTransactionId(), +        mAssetType(LLAssetType::AT_NONE), +        mFolderId(LLUUID::null), +        mItemId(LLUUID::null), +        mAssetId(LLAssetID::null) +    { } + +    void                setTransactionId(LLTransactionID tid) { mTransactionId = tid; } +    void                setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; } + +    LLAssetID           generateNewAssetId(); +    void                incrementUploadStats() const; +    virtual void        assignDefaults(); + +private: +    LLTransactionID     mTransactionId; +    LLAssetType::EType  mAssetType; +    std::string         mName; +    std::string         mDescription; +    S32                 mCompressionInfo; +    LLFolderType::EType mDestinationFolderType; +    LLInventoryType::EType mInventoryType; +    U32                 mNextOwnerPerms; +    U32                 mGroupPerms; +    U32                 mEveryonePerms; +    S32                 mExpectedUploadCost; + +    LLUUID              mFolderId; +    LLUUID              mItemId; +    LLAssetID           mAssetId; +}; + +class NewFileResourceUploadInfo : public NewResourceUploadInfo +{ +public: +    NewFileResourceUploadInfo( +        std::string fileName, +        std::string name, +        std::string description, +        S32 compressionInfo, +        LLFolderType::EType destinationType, +        LLInventoryType::EType inventoryType, +        U32 nextOWnerPerms, +        U32 groupPerms, +        U32 everyonePerms, +        S32 expectedCost); + +    virtual LLSD        prepareUpload(); + +    std::string         getFileName() const { return mFileName; }; + +protected: + +    virtual LLSD        exportTempFile(); + +private: +    std::string         mFileName; + +}; + +#if 0 +class NotecardResourceUploadInfo : public NewResourceUploadInfo +{ +public: +    NotecardResourceUploadInfo( +        ); + + +protected: + +private: +}; +#endif  class LLViewerAssetUpload  { diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 20fbfaf71a..9c4045fa1e 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -451,39 +451,6 @@ class LLFileUploadBulk : public view_listener_t                  filename = picker.getNextFile();              } -#if 0 -			const std::string& filename = picker.getFirstFile(); -			std::string name = gDirUtilp->getBaseFileName(filename, true); -			 -			std::string asset_name = name; -			LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); -			LLStringUtil::replaceChar(asset_name, '|', '?'); -			LLStringUtil::stripNonprintable(asset_name); -			LLStringUtil::trim(asset_name); -			 -			std::string display_name = LLStringUtil::null; -			LLAssetStorage::LLStoreAssetCallback callback = NULL; -			S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); -			void *userdata = NULL; - -			upload_new_resource( -				filename, -				asset_name, -				asset_name, -				0, -				LLFolderType::FT_NONE, -				LLInventoryType::IT_NONE, -				LLFloaterPerms::getNextOwnerPerms("Uploads"), -				LLFloaterPerms::getGroupPerms("Uploads"), -				LLFloaterPerms::getEveryonePerms("Uploads"), -				display_name, -				callback, -				expected_upload_cost, -				userdata); - -			// *NOTE: Ew, we don't iterate over the file list here, -			// we handle the next files in upload_done_callback() -#endif  		}  		else  		{ @@ -678,151 +645,6 @@ LLUUID upload_new_resource(      upload_new_resource(uploadInfo, callback, userdata);      return LLUUID::null; - -#if 0 -	// Generate the temporary UUID. -	std::string filename = gDirUtilp->getTempFilename(); -	LLTransactionID tid; -	LLAssetID uuid; -	 -	LLSD args; - -	std::string exten = gDirUtilp->getExtension(src_filename); -	U32 codec = LLImageBase::getCodecFromExtension(exten); -	LLAssetType::EType asset_type = LLAssetType::AT_NONE; -	std::string error_message; - -	BOOL error = FALSE; -	 -	if (exten.empty()) -	{ -		std::string short_name = gDirUtilp->getBaseFileName(filename); -		 -		// No extension -		error_message = llformat( -				"No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", -				short_name.c_str()); -		args["FILE"] = short_name; - 		upload_error(error_message, "NoFileExtension", filename, args); -		return LLUUID(); -	} -	else if (codec != IMG_CODEC_INVALID) -	{ -		// It's an image file, the upload procedure is the same for all -		asset_type = LLAssetType::AT_TEXTURE; -		if (!LLViewerTextureList::createUploadFile(src_filename, filename, codec )) -		{ -			error_message = llformat( "Problem with file %s:\n\n%s\n", -									 src_filename.c_str(), LLImage::getLastError().c_str()); -			args["FILE"] = src_filename; -			args["ERROR"] = LLImage::getLastError(); -			upload_error(error_message, "ProblemWithFile", filename, args); -			return LLUUID(); -		} -	} -	else if(exten == "wav") -	{ -		asset_type = LLAssetType::AT_SOUND;  // tag it as audio -		S32 encode_result = 0; - -		LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL; - -		encode_result = encode_vorbis_file(src_filename, filename); -		 -		if (LLVORBISENC_NOERR != encode_result) -		{ -			switch(encode_result) -			{ -				case LLVORBISENC_DEST_OPEN_ERR: -				    error_message = llformat( "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); -					args["FILE"] = filename; -					upload_error(error_message, "CannotOpenTemporarySoundFile", filename, args); -					break; - -				default:	 -				  error_message = llformat("Unknown vorbis encode failure on: %s\n", src_filename.c_str()); -					args["FILE"] = src_filename; -					upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args); -					break;	 -			}	 -			return LLUUID(); -		} -	} -	else if (exten == "bvh") -	{ -		error_message = llformat("We do not currently support bulk upload of animation files\n"); -		upload_error(error_message, "DoNotSupportBulkAnimationUpload", filename, args); -		return LLUUID(); -	} -	else if (exten == "anim") -	{ -		asset_type = LLAssetType::AT_ANIMATION; -		filename = src_filename; -	} -	else -	{ -		// Unknown extension -		error_message = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str()); -		error = TRUE;; -	} - -	// gen a new transaction ID for this asset -	tid.generate(); - -	if (!error) -	{ -		uuid = tid.makeAssetID(gAgent.getSecureSessionID()); -		// copy this file into the vfs for upload -		S32 file_size; -		LLAPRFile infile ; -		infile.open(filename, LL_APR_RB, NULL, &file_size); -		if (infile.getFileHandle()) -		{ -			LLVFile file(gVFS, uuid, asset_type, LLVFile::WRITE); - -			file.setMaxSize(file_size); - -			const S32 buf_size = 65536; -			U8 copy_buf[buf_size]; -			while ((file_size = infile.read(copy_buf, buf_size))) -			{ -				file.write(copy_buf, file_size); -			} -		} -		else -		{ -			error_message = llformat( "Unable to access output file: %s", filename.c_str()); -			error = TRUE; -		} -	} - -	if (!error) -	{ -        NewResourceUploadInfo::ptr_t uploadInfo(new NewResourceUploadInfo( -            tid, asset_type, -            name, desc, compression_info, -            destination_folder_type, inv_type, -            next_owner_perms, group_perms, everyone_perms, -            expected_upload_cost)); - -        upload_new_resource(uploadInfo,  -                callback, userdata); -	} -	else -	{ -		LL_WARNS() << error_message << LL_ENDL; -		LLSD args; -		args["ERROR_MESSAGE"] = error_message; -		LLNotificationsUtil::add("ErrorMessage", args); -		if(LLFile::remove(filename) == -1) -		{ -			LL_DEBUGS() << "unable to remove temp file" << LL_ENDL; -		} -		LLFilePicker::instance().reset(); -	} - -	return uuid; -#endif  }  void upload_done_callback( @@ -1047,349 +869,3 @@ void init_menu_file()  	// "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled.  } - -LLSD NewResourceUploadInfo::prepareUpload() -{ -    if (mAssetId.isNull()) -        generateNewAssetId(); - -    incrementUploadStats(); -    assignDefaults(); - -    return LLSD().with("success", LLSD::Boolean(true)); -} - -std::string NewResourceUploadInfo::getAssetTypeString() const -{ -    return LLAssetType::lookup(mAssetType); -} - -std::string NewResourceUploadInfo::getInventoryTypeString() const -{ -    return LLInventoryType::lookup(mInventoryType); -} - -LLSD NewResourceUploadInfo::generatePostBody() -{ -    LLSD body; - -    body["folder_id"] = mFolderId; -    body["asset_type"] = getAssetTypeString(); -    body["inventory_type"] = getInventoryTypeString(); -    body["name"] = mName; -    body["description"] = mDescription; -    body["next_owner_mask"] = LLSD::Integer(mNextOwnerPerms); -    body["group_mask"] = LLSD::Integer(mGroupPerms); -    body["everyone_mask"] = LLSD::Integer(mEveryonePerms); - -    return body; - -} - -void NewResourceUploadInfo::logPreparedUpload() -{ -    LL_INFOS() << "*** Uploading: " << std::endl <<  -        "Type: " << LLAssetType::lookup(mAssetType) << std::endl << -        "UUID: " << mAssetId.asString() << std::endl <<  -        "Name: " << mName << std::endl <<  -        "Desc: " << mDescription << std::endl << -        "Expected Upload Cost: " << mExpectedUploadCost << std::endl << -        "Folder: " << mFolderId << std::endl << -        "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL; -} - -LLUUID NewResourceUploadInfo::finishUpload(LLSD &result) -{ -    if (getFolderId().isNull()) -    { -        return LLUUID::null; -    } - -    U32 permsEveryone = PERM_NONE; -    U32 permsGroup = PERM_NONE; -    U32 permsNextOwner = PERM_ALL; - -    if (result.has("new_next_owner_mask")) -    { -        // The server provided creation perms so use them. -        // Do not assume we got the perms we asked for in -        // since the server may not have granted them all. -        permsEveryone = result["new_everyone_mask"].asInteger(); -        permsGroup = result["new_group_mask"].asInteger(); -        permsNextOwner = result["new_next_owner_mask"].asInteger(); -    } -    else -    { -        // The server doesn't provide creation perms -        // so use old assumption-based perms. -        if (getAssetTypeString() != "snapshot") -        { -            permsNextOwner = PERM_MOVE | PERM_TRANSFER; -        } -    } - -    LLPermissions new_perms; -    new_perms.init( -        gAgent.getID(), -        gAgent.getID(), -        LLUUID::null, -        LLUUID::null); - -    new_perms.initMasks( -        PERM_ALL, -        PERM_ALL, -        permsEveryone, -        permsGroup, -        permsNextOwner); - -    U32 flagsInventoryItem = 0; -    if (result.has("inventory_flags")) -    { -        flagsInventoryItem = static_cast<U32>(result["inventory_flags"].asInteger()); -        if (flagsInventoryItem != 0) -        { -            LL_INFOS() << "inventory_item_flags " << flagsInventoryItem << LL_ENDL; -        } -    } -    S32 creationDate = time_corrected(); - -    LLUUID serverInventoryItem = result["new_inventory_item"].asUUID(); -    LLUUID serverAssetId = result["new_asset"].asUUID(); - -    LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem( -        serverInventoryItem, -        getFolderId(), -        new_perms, -        serverAssetId, -        getAssetType(), -        getInventoryType(), -        getName(), -        getDescription(), -        LLSaleInfo::DEFAULT, -        flagsInventoryItem, -        creationDate); - -    gInventory.updateItem(item); -    gInventory.notifyObservers(); - -    return serverInventoryItem; -} - - -LLAssetID NewResourceUploadInfo::generateNewAssetId() -{ -    if (gDisconnected) -    { -        LLAssetID rv; - -        rv.setNull(); -        return rv; -    } -    mAssetId = mTransactionId.makeAssetID(gAgent.getSecureSessionID()); - -    return mAssetId; -} - -void NewResourceUploadInfo::incrementUploadStats() const -{ -    if (LLAssetType::AT_SOUND == mAssetType) -    { -        add(LLStatViewer::UPLOAD_SOUND, 1); -    } -    else if (LLAssetType::AT_TEXTURE == mAssetType) -    { -        add(LLStatViewer::UPLOAD_TEXTURE, 1); -    } -    else if (LLAssetType::AT_ANIMATION == mAssetType) -    { -        add(LLStatViewer::ANIMATION_UPLOADS, 1); -    } -} - -void NewResourceUploadInfo::assignDefaults() -{ -    if (LLInventoryType::IT_NONE == mInventoryType) -    { -        mInventoryType = LLInventoryType::defaultForAssetType(mAssetType); -    } -    LLStringUtil::stripNonprintable(mName); -    LLStringUtil::stripNonprintable(mDescription); - -    if (mName.empty()) -    { -        mName = "(No Name)"; -    } -    if (mDescription.empty()) -    { -        mDescription = "(No Description)"; -    } - -    mFolderId = gInventory.findCategoryUUIDForType( -        (mDestinationFolderType == LLFolderType::FT_NONE) ? -        (LLFolderType::EType)mAssetType : mDestinationFolderType); - -} - -std::string NewResourceUploadInfo::getDisplayName() const -{  -    return (mName.empty()) ? mAssetId.asString() : mName;  -}; - - -NewFileResourceUploadInfo::NewFileResourceUploadInfo( -        std::string fileName, -        std::string name, -        std::string description, -        S32 compressionInfo, -        LLFolderType::EType destinationType, -        LLInventoryType::EType inventoryType, -        U32 nextOWnerPerms, -        U32 groupPerms, -        U32 everyonePerms, -        S32 expectedCost): -    NewResourceUploadInfo(name, description, compressionInfo, -        destinationType, inventoryType, -        nextOWnerPerms, groupPerms, everyonePerms, expectedCost), -    mFileName(fileName) -{ -    LLTransactionID tid; -    tid.generate(); -    setTransactionId(tid); -} - - - -LLSD NewFileResourceUploadInfo::prepareUpload() -{ -    generateNewAssetId(); - -    LLSD result = exportTempFile(); -    if (result.has("error")) -        return result; - -    return NewResourceUploadInfo::prepareUpload(); -} - -LLSD NewFileResourceUploadInfo::exportTempFile() -{ -    std::string filename = gDirUtilp->getTempFilename(); - -    std::string exten = gDirUtilp->getExtension(getFileName()); -    U32 codec = LLImageBase::getCodecFromExtension(exten); - -    LLAssetType::EType assetType = LLAssetType::AT_NONE; -    std::string errorMessage; -    std::string errorLabel; - -    bool error = false; - -    if (exten.empty()) -    { -        std::string shortName = gDirUtilp->getBaseFileName(filename); - -        // No extension -        errorMessage = llformat( -            "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", -            shortName.c_str()); -        errorLabel = "NoFileExtension"; -        error = true; -    } -    else if (codec != IMG_CODEC_INVALID) -    { -        // It's an image file, the upload procedure is the same for all -        assetType = LLAssetType::AT_TEXTURE; -        if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec)) -        { -            errorMessage = llformat("Problem with file %s:\n\n%s\n", -                getFileName().c_str(), LLImage::getLastError().c_str()); -            errorLabel = "ProblemWithFile"; -            error = true; -        } -    } -    else if (exten == "wav") -    { -        assetType = LLAssetType::AT_SOUND;  // tag it as audio -        S32 encodeResult = 0; - -        LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL; - -        encodeResult = encode_vorbis_file(getFileName(), filename); - -        if (LLVORBISENC_NOERR != encodeResult) -        { -            switch (encodeResult) -            { -            case LLVORBISENC_DEST_OPEN_ERR: -                errorMessage = llformat("Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); -                errorLabel = "CannotOpenTemporarySoundFile"; -                break; - -            default: -                errorMessage = llformat("Unknown vorbis encode failure on: %s\n", getFileName().c_str()); -                errorLabel = "UnknownVorbisEncodeFailure"; -                break; -            } -            error = true; -        } -    } -    else if (exten == "bvh") -    { -        errorMessage = llformat("We do not currently support bulk upload of animation files\n"); -        errorLabel = "DoNotSupportBulkAnimationUpload"; -        error = true; -    } -    else if (exten == "anim") -    { -        assetType = LLAssetType::AT_ANIMATION; -        filename = getFileName(); -    } -    else -    { -        // Unknown extension -        errorMessage = llformat(LLTrans::getString("UnknownFileExtension").c_str(), exten.c_str()); -        errorLabel = "ErrorMessage"; -        error = TRUE;; -    } - -    if (error) -    { -        LLSD errorResult(LLSD::emptyMap()); - -        errorResult["error"] = LLSD::Binary(true); -        errorResult["message"] = errorMessage; -        errorResult["label"] = errorLabel; -        return errorResult; -    } - -    setAssetType(assetType); - -    // copy this file into the vfs for upload -    S32 file_size; -    LLAPRFile infile; -    infile.open(filename, LL_APR_RB, NULL, &file_size); -    if (infile.getFileHandle()) -    { -        LLVFile file(gVFS, getAssetId(), assetType, LLVFile::WRITE); - -        file.setMaxSize(file_size); - -        const S32 buf_size = 65536; -        U8 copy_buf[buf_size]; -        while ((file_size = infile.read(copy_buf, buf_size))) -        { -            file.write(copy_buf, file_size); -        } -    } -    else -    { -        errorMessage = llformat("Unable to access output file: %s", filename.c_str()); -        LLSD errorResult(LLSD::emptyMap()); - -        errorResult["error"] = LLSD::Binary(true); -        errorResult["message"] = errorMessage; -        return errorResult; -    } - -    return LLSD(); - -} diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 7ee5043777..616eaed373 100755 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -34,155 +34,13 @@  #include "llthread.h"  #include <queue> +#include "llviewerassetupload.h" +  class LLTransactionID;  void init_menu_file(); -class NewResourceUploadInfo -{ -public: -    typedef boost::shared_ptr<NewResourceUploadInfo> ptr_t; - -    NewResourceUploadInfo( -            LLTransactionID transactId, -            LLAssetType::EType assetType, -            std::string name,  -            std::string description,  -            S32 compressionInfo, -            LLFolderType::EType destinationType, -            LLInventoryType::EType inventoryType, -            U32 nextOWnerPerms,  -            U32 groupPerms,  -            U32 everyonePerms,  -            S32 expectedCost) : -        mTransactionId(transactId), -        mAssetType(assetType), -        mName(name), -        mDescription(description), -        mCompressionInfo(compressionInfo), -        mDestinationFolderType(destinationType), -        mInventoryType(inventoryType), -        mNextOwnerPerms(nextOWnerPerms), -        mGroupPerms(groupPerms), -        mEveryonePerms(everyonePerms), -        mExpectedUploadCost(expectedCost), -        mFolderId(LLUUID::null), -        mItemId(LLUUID::null), -        mAssetId(LLAssetID::null) -    { } - -    virtual ~NewResourceUploadInfo() -    { } - -    virtual LLSD        prepareUpload(); -    virtual LLSD        generatePostBody(); -    virtual void        logPreparedUpload(); -    virtual LLUUID      finishUpload(LLSD &result); - -    //void                setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; } -    //void                setTransactionId(LLTransactionID transactionId) { mTransactionId = transactionId; } - -    LLTransactionID     getTransactionId() const { return mTransactionId; } -    LLAssetType::EType  getAssetType() const { return mAssetType; } -    std::string         getAssetTypeString() const; -    std::string         getName() const { return mName; }; -    std::string         getDescription() const { return mDescription; }; -    S32                 getCompressionInfo() const { return mCompressionInfo; }; -    LLFolderType::EType getDestinationFolderType() const { return mDestinationFolderType; }; -    LLInventoryType::EType  getInventoryType() const { return mInventoryType; }; -    std::string         getInventoryTypeString() const; -    U32                 getNextOwnerPerms() const { return mNextOwnerPerms; }; -    U32                 getGroupPerms() const { return mGroupPerms; }; -    U32                 getEveryonePerms() const { return mEveryonePerms; }; -    S32                 getExpectedUploadCost() const { return mExpectedUploadCost; }; - -    virtual std::string getDisplayName() const; - -    LLUUID              getFolderId() const { return mFolderId; } -    LLUUID              getItemId() const { return mItemId; } -    LLAssetID           getAssetId() const { return mAssetId; } - -protected: -    NewResourceUploadInfo( -            std::string name, -            std::string description, -            S32 compressionInfo, -            LLFolderType::EType destinationType, -            LLInventoryType::EType inventoryType, -            U32 nextOWnerPerms, -            U32 groupPerms, -            U32 everyonePerms, -            S32 expectedCost) : -        mName(name), -        mDescription(description), -        mCompressionInfo(compressionInfo), -        mDestinationFolderType(destinationType), -        mInventoryType(inventoryType), -        mNextOwnerPerms(nextOWnerPerms), -        mGroupPerms(groupPerms), -        mEveryonePerms(everyonePerms), -        mExpectedUploadCost(expectedCost), -        mTransactionId(), -        mAssetType(LLAssetType::AT_NONE), -        mFolderId(LLUUID::null), -        mItemId(LLUUID::null), -        mAssetId(LLAssetID::null) -    { } - -    void                setTransactionId(LLTransactionID tid) { mTransactionId = tid; } -    void                setAssetType(LLAssetType::EType assetType) { mAssetType = assetType; } - -    LLAssetID           generateNewAssetId(); -    void                incrementUploadStats() const; -    virtual void        assignDefaults(); - -private: -    LLTransactionID     mTransactionId; -    LLAssetType::EType  mAssetType; -    std::string         mName; -    std::string         mDescription; -    S32                 mCompressionInfo; -    LLFolderType::EType mDestinationFolderType; -    LLInventoryType::EType mInventoryType; -    U32                 mNextOwnerPerms; -    U32                 mGroupPerms; -    U32                 mEveryonePerms; -    S32                 mExpectedUploadCost; - -    LLUUID              mFolderId; -    LLUUID              mItemId; -    LLAssetID           mAssetId; -}; - -class NewFileResourceUploadInfo : public NewResourceUploadInfo -{ -public: -    NewFileResourceUploadInfo( -        std::string fileName, -        std::string name, -        std::string description, -        S32 compressionInfo, -        LLFolderType::EType destinationType, -        LLInventoryType::EType inventoryType, -        U32 nextOWnerPerms, -        U32 groupPerms, -        U32 everyonePerms, -        S32 expectedCost); - -    virtual LLSD        prepareUpload(); - -    std::string         getFileName() const { return mFileName; }; - -protected: - -    virtual LLSD        exportTempFile(); - -private: -    std::string         mFileName; - -}; -  LLUUID upload_new_resource(      const std::string& src_filename, diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index 066970614a..5828aee7fc 100755 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -390,7 +390,7 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip)  	mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler( mHttpRequest, this ));  	mPostH = mHttpRequest->requestPost(LLCore::HttpRequest::DEFAULT_POLICY_ID, 0,  -		mURI, body.get(), httpOpts.get(), httpHeaders.get(), mHandler.get()); +		mURI, body.get(), httpOpts, httpHeaders, mHandler.get());  } diff --git a/indra/newview/tests/llhttpretrypolicy_test.cpp b/indra/newview/tests/llhttpretrypolicy_test.cpp index 25e6de46d9..8bd6cc2690 100755 --- a/indra/newview/tests/llhttpretrypolicy_test.cpp +++ b/indra/newview/tests/llhttpretrypolicy_test.cpp @@ -285,10 +285,10 @@ void RetryPolicyTestObject::test<7>()  	ensure_approximately_equals_range("header 2", seconds_to_wait, 7.0F, 2.0F);  	LLCore::HttpResponse *response; -	LLCore::HttpHeaders *headers; +	LLCore::HttpHeaders::ptr_t headers;  	response = new LLCore::HttpResponse(); -	headers = new LLCore::HttpHeaders(); +	headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders());  	response->setStatus(503);  	response->setHeaders(headers);  	headers->append(HTTP_IN_HEADER_RETRY_AFTER, std::string("600")); @@ -299,7 +299,7 @@ void RetryPolicyTestObject::test<7>()  	response->release();  	response = new LLCore::HttpResponse(); -	headers = new LLCore::HttpHeaders(); +	headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders());  	response->setStatus(503);  	response->setHeaders(headers);  	time(&nowseconds); | 
