diff options
Diffstat (limited to 'indra/llmessage/llcurl.h')
-rwxr-xr-x[-rw-r--r--] | indra/llmessage/llcurl.h | 88 |
1 files changed, 75 insertions, 13 deletions
diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h index fd664c0fa1..90b3f2815d 100644..100755 --- a/indra/llmessage/llcurl.h +++ b/indra/llmessage/llcurl.h @@ -44,6 +44,8 @@ #include "llthread.h" #include "llqueuedthread.h" #include "llframetimer.h" +#include "llpointer.h" +#include "llsingleton.h" class LLMutex; class LLCurlThread; @@ -67,7 +69,7 @@ public: F64 mSpeedDownload; }; - class Responder + class Responder : public LLThreadSafeRefCount { //LOG_CLASS(Responder); public: @@ -126,13 +128,10 @@ public: return false; } - public: /* but not really -- don't touch this */ - U32 mReferenceCount; - private: std::string mURL; }; - typedef boost::intrusive_ptr<Responder> ResponderPtr; + typedef LLPointer<Responder> ResponderPtr; /** @@ -189,6 +188,8 @@ public: static CURL* newEasyHandle() ; static void deleteEasyHandle(CURL* handle) ; + static CURL* createStandardCurlHandle(); + private: static std::string sCAPath; static std::string sCAFile; @@ -198,6 +199,7 @@ private: static LLMutex* sHandleMutexp ; static S32 sTotalHandles ; static S32 sMaxHandles; + static CURL* sCurlTemplateStandardHandle; public: static bool sNotQuitting; static F32 sCurlRequestTimeOut; @@ -304,7 +306,7 @@ public: ePerformState getState() ; bool isCompleted() ; - bool isValid() {return mCurlMultiHandle != NULL ;} + bool isValid() {return mCurlMultiHandle != NULL && mValid;} bool isDead() {return mDead;} bool waitToComplete() ; @@ -318,7 +320,7 @@ public: private: void easyFree(LLCurl::Easy*); - void cleanup() ; + void cleanup(bool deleted = false) ; CURLM* mCurlMultiHandle; @@ -333,6 +335,7 @@ private: ePerformState mState; BOOL mDead ; + BOOL mValid ; LLMutex* mMutexp ; LLMutex* mDeletionMutexp ; LLMutex* mEasyMutexp ; @@ -377,12 +380,6 @@ private: void cleanupMulti(LLCurl::Multi* multi) ; } ; -namespace boost -{ - void intrusive_ptr_add_ref(LLCurl::Responder* p); - void intrusive_ptr_release(LLCurl::Responder* p); -}; - class LLCurlRequest { @@ -413,6 +410,71 @@ private: BOOL mProcessing; }; +//for texture fetch only +class LLCurlTextureRequest : public LLCurlRequest +{ +public: + LLCurlTextureRequest(S32 concurrency); + ~LLCurlTextureRequest(); + + U32 getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, U32 pri, LLCurl::ResponderPtr responder, F32 delay_time = -1.f); + void nextRequests(); + void completeRequest(S32 received_bytes); + + void updatePriority(U32 handle, U32 pri); + void removeRequest(U32 handle); + + U32 getTotalReceivedBits(); + U32 getTotalIssuedRequests(); + S32 getNumRequests(); + bool isWaiting(U32 handle); + +private: + LLMutex mMutex; + S32 mConcurrency; + S32 mInQueue; //request currently in queue. + U32 mHandleCounter; + U32 mTotalIssuedRequests; + U32 mTotalReceivedBits; + + typedef struct _request_t + { + _request_t(U32 handle, const std::string& url, const headers_t& headers, S32 offset, S32 length, U32 pri, LLCurl::ResponderPtr responder) : + mHandle(handle), mUrl(url), mHeaders(headers), mOffset(offset), mLength(length), mPriority(pri), mResponder(responder), mStartTime(0.f) + {} + + U32 mHandle; + std::string mUrl; + LLCurlRequest::headers_t mHeaders; + S32 mOffset; + S32 mLength; + LLCurl::ResponderPtr mResponder; + U32 mPriority; + F32 mStartTime; //start time to issue this request + } request_t; + + struct request_compare + { + bool operator()(const request_t* lhs, const request_t* rhs) const + { + if(lhs->mPriority != rhs->mPriority) + { + return lhs->mPriority > rhs->mPriority; // higher priority in front of queue (set) + } + else + { + return (U32)lhs < (U32)rhs; + } + } + }; + + typedef std::set<request_t*, request_compare> req_queue_t; + req_queue_t mCachedRequests; + std::map<S32, request_t*> mRequestMap; + + LLFrameTimer mGlobalTimer; +}; + class LLCurlEasyRequest { public: |