diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llmessage/llcurl.cpp | 32 | ||||
-rw-r--r-- | indra/llmessage/llcurl.h | 10 |
2 files changed, 30 insertions, 12 deletions
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index 7f61e1ac04..7ca25d07fc 100644 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -797,9 +797,10 @@ void LLCurl::Multi::removeEasy(Easy* easy) //------------------------------------------------------------ //LLCurlThread -LLCurlThread::CurlRequest::CurlRequest(handle_t handle, LLCurl::Multi* multi) : +LLCurlThread::CurlRequest::CurlRequest(handle_t handle, LLCurl::Multi* multi, LLCurlThread* curl_thread) : LLQueuedThread::QueuedRequest(handle, LLQueuedThread::PRIORITY_NORMAL, FLAG_AUTO_COMPLETE), - mMulti(multi) + mMulti(multi), + mCurlThread(curl_thread) { } @@ -807,7 +808,7 @@ LLCurlThread::CurlRequest::~CurlRequest() { if(mMulti) { - delete mMulti ; + mCurlThread->deleteMulti(mMulti) ; mMulti = NULL ; } } @@ -817,7 +818,7 @@ bool LLCurlThread::CurlRequest::processRequest() bool completed = true ; if(mMulti) { - completed = mMulti->doPerform() ; + completed = mCurlThread->doMultiPerform(mMulti) ; setPriority(LLQueuedThread::PRIORITY_LOW) ; } @@ -826,7 +827,7 @@ bool LLCurlThread::CurlRequest::processRequest() void LLCurlThread::CurlRequest::finishRequest(bool completed) { - delete mMulti ; + mCurlThread->deleteMulti(mMulti) ; mMulti = NULL ; } @@ -849,7 +850,7 @@ void LLCurlThread::addMulti(LLCurl::Multi* multi) { multi->mHandle = generateHandle() ; - CurlRequest* req = new CurlRequest(multi->mHandle, multi) ; + CurlRequest* req = new CurlRequest(multi->mHandle, multi, this) ; if (!addRequest(req)) { @@ -857,11 +858,22 @@ void LLCurlThread::addMulti(LLCurl::Multi* multi) } } -void LLCurlThread::deleteMulti(LLCurl::Multi* multi) +void LLCurlThread::killMulti(LLCurl::Multi* multi) { multi->markDead() ; } +//private +bool LLCurlThread::doMultiPerform(LLCurl::Multi* multi) +{ + return multi->doPerform() ; +} + +//private +void LLCurlThread::deleteMulti(LLCurl::Multi* multi) +{ + delete multi ; +} //------------------------------------------------------------ //static @@ -886,7 +898,7 @@ LLCurlRequest::~LLCurlRequest() //stop all Multi handle background threads for (curlmulti_set_t::iterator iter = mMultiSet.begin(); iter != mMultiSet.end(); ++iter) { - LLCurl::getCurlThread()->deleteMulti(*iter) ; + LLCurl::getCurlThread()->killMulti(*iter) ; } mMultiSet.clear() ; } @@ -1023,7 +1035,7 @@ S32 LLCurlRequest::process() if (multi != mActiveMulti && tres == 0 && multi->mQueued == 0) { mMultiSet.erase(curiter); - LLCurl::getCurlThread()->deleteMulti(multi); + LLCurl::getCurlThread()->killMulti(multi); } } mProcessing = FALSE; @@ -1069,7 +1081,7 @@ LLCurlEasyRequest::LLCurlEasyRequest() LLCurlEasyRequest::~LLCurlEasyRequest() { - LLCurl::getCurlThread()->deleteMulti(mMulti) ; + LLCurl::getCurlThread()->killMulti(mMulti) ; } void LLCurlEasyRequest::setopt(CURLoption option, S32 value) diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h index 23a6ca67e3..a275db3e53 100644 --- a/indra/llmessage/llcurl.h +++ b/indra/llmessage/llcurl.h @@ -328,7 +328,7 @@ public: virtual ~CurlRequest(); // use deleteRequest() public: - CurlRequest(handle_t handle, LLCurl::Multi* multi); + CurlRequest(handle_t handle, LLCurl::Multi* multi, LLCurlThread* curl_thread); /*virtual*/ bool processRequest(); /*virtual*/ void finishRequest(bool completed); @@ -336,8 +336,10 @@ public: private: // input LLCurl::Multi* mMulti; + LLCurlThread* mCurlThread; }; - + friend class CurlRequest; + public: LLCurlThread(bool threaded = true) ; virtual ~LLCurlThread() ; @@ -345,6 +347,10 @@ public: S32 update(U32 max_time_ms); void addMulti(LLCurl::Multi* multi) ; + void killMulti(LLCurl::Multi* multi) ; + +private: + bool doMultiPerform(LLCurl::Multi* multi) ; void deleteMulti(LLCurl::Multi* multi) ; } ; |