summaryrefslogtreecommitdiff
path: root/indra/newview/llappviewer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r--indra/newview/llappviewer.cpp189
1 files changed, 5 insertions, 184 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 0549a972e1..f8ee1a477f 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -215,10 +215,6 @@
#include "llmachineid.h"
#include "llmainlooprepeater.h"
-// LLCore::HTTP
-#include "httpcommon.h"
-#include "httprequest.h"
-#include "httphandler.h"
// *FIX: These extern globals should be cleaned up.
// The globals either represent state/config/resource-storage of either
@@ -334,53 +330,6 @@ static std::string gLaunchFileOnQuit;
// Used on Win32 for other apps to identify our window (eg, win_setup)
const char* const VIEWER_WINDOW_CLASSNAME = "Second Life";
-namespace
-{
-
-// This class manages the lifecyle of the core http library.
-// Slightly different style than traditional code but reflects
-// the use of handler classes and light-weight interface
-// object instances of the new libraries. To be used
-// as a singleton and static construction is fine.
-class CoreHttp : public LLCore::HttpHandler
-{
-public:
- CoreHttp();
- ~CoreHttp();
-
- // Initialize the LLCore::HTTP library creating service classes
- // and starting the servicing thread. Caller is expected to do
- // other initializations (SSL mutex, thread hash function) appropriate
- // for the application.
- void init();
-
- // Request that the servicing thread stop servicing requests,
- // release resource references and stop.
- void requestStop();
-
- // Terminate LLCore::HTTP library services. Caller is expected
- // to have made a best-effort to shutdown the servicing thread
- // by issuing a requestThreadStop() and waiting for completion
- // notification that the stop has completed.
- void cleanup();
-
- // Notification when the stop request is complete.
- virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response);
-
-private:
- static const F64 MAX_THREAD_WAIT_TIME;
-
-private:
- LLCore::HttpRequest * mRequest;
- LLCore::HttpHandle mStopHandle;
- F64 mStopRequested;
- bool mStopped;
-};
-
-CoreHttp coreHttpLib;
-
-} // end anonymous namespace
-
//-- LLDeferredTaskList ------------------------------------------------------
/**
@@ -775,8 +724,9 @@ bool LLAppViewer::init()
LLViewerStatsRecorder::initClass();
#endif
- // Initialize the non-LLCurl libcurl library
- coreHttpLib.init();
+ // Initialize the non-LLCurl libcurl library. Should be called
+ // before consumers (LLTextureFetch).
+ mAppCoreHttp.init();
// *NOTE:Mani - LLCurl::initClass is not thread safe.
// Called before threads are created.
@@ -1915,7 +1865,7 @@ bool LLAppViewer::cleanup()
// Delete workers first
// shotdown all worker threads before deleting them in case of co-dependencies
- coreHttpLib.requestStop();
+ mAppCoreHttp.requestStop();
sTextureFetch->shutdown();
sTextureCache->shutdown();
sImageDecodeThread->shutdown();
@@ -2000,7 +1950,7 @@ bool LLAppViewer::cleanup()
LLCurl::cleanupClass();
// Non-LLCurl libcurl library
- coreHttpLib.cleanup();
+ mAppCoreHttp.cleanup();
// If we're exiting to launch an URL, do that here so the screen
// is at the right resolution before we launch IE.
@@ -5298,132 +5248,3 @@ void LLAppViewer::metricsSend(bool enable_reporting)
gViewerAssetStatsMain->reset();
}
-namespace
-{
-
-const F64 CoreHttp::MAX_THREAD_WAIT_TIME(10.0);
-
-CoreHttp::CoreHttp()
- : mRequest(NULL),
- mStopHandle(LLCORE_HTTP_HANDLE_INVALID),
- mStopRequested(0.0),
- mStopped(false)
-{}
-
-
-CoreHttp::~CoreHttp()
-{
- delete mRequest;
- mRequest = NULL;
-}
-
-
-void CoreHttp::init()
-{
- LLCore::HttpStatus status = LLCore::HttpRequest::createService();
- if (! status)
- {
- LL_ERRS("Init") << "Failed to initialize HTTP services. Reason: "
- << status.toString()
- << LL_ENDL;
- }
-
- // Point to our certs or SSH/https: will fail on connect
- status = LLCore::HttpRequest::setPolicyGlobalOption(LLCore::HttpRequest::GP_CA_FILE,
- gDirUtilp->getCAFile());
- if (! status)
- {
- LL_ERRS("Init") << "Failed to set CA File for HTTP services. Reason: "
- << status.toString()
- << LL_ENDL;
- }
-
- // Establish HTTP Proxy. "LLProxy" is a special string which directs
- // the code to use LLProxy::applyProxySettings() to establish any
- // HTTP or SOCKS proxy for http operations.
- status = LLCore::HttpRequest::setPolicyGlobalOption(LLCore::HttpRequest::GP_LLPROXY, 1);
- if (! status)
- {
- LL_ERRS("Init") << "Failed to set HTTP proxy for HTTP services. Reason: "
- << status.toString()
- << LL_ENDL;
- }
-
- // Tracing levels for library & libcurl (note that 2 & 3 are beyond spammy):
- // 0 - None
- // 1 - Basic start, stop simple transitions
- // 2 - libcurl CURLOPT_VERBOSE mode with brief lines
- // 3 - with partial data content
- status = LLCore::HttpRequest::setPolicyGlobalOption(LLCore::HttpRequest::GP_TRACE, 0);
-
- // Kick the thread
- status = LLCore::HttpRequest::startThread();
- if (! status)
- {
- LL_ERRS("Init") << "Failed to start HTTP servicing thread. Reason: "
- << status.toString()
- << LL_ENDL;
- }
-
- mRequest = new LLCore::HttpRequest;
-}
-
-
-void CoreHttp::requestStop()
-{
- llassert_always(mRequest);
-
- mStopHandle = mRequest->requestStopThread(this);
- if (LLCORE_HTTP_HANDLE_INVALID != mStopHandle)
- {
- mStopRequested = LLTimer::getTotalSeconds();
- }
-}
-
-
-void CoreHttp::cleanup()
-{
- if (LLCORE_HTTP_HANDLE_INVALID == mStopHandle)
- {
- // Should have been started already...
- requestStop();
- }
-
- if (LLCORE_HTTP_HANDLE_INVALID == mStopHandle)
- {
- LL_WARNS("Cleanup") << "Attempting to cleanup HTTP services without thread shutdown"
- << LL_ENDL;
- }
- else
- {
- while (! mStopped && LLTimer::getTotalSeconds() < (mStopRequested + MAX_THREAD_WAIT_TIME))
- {
- mRequest->update(200000);
- ms_sleep(50);
- }
- if (! mStopped)
- {
- LL_WARNS("Cleanup") << "Attempting to cleanup HTTP services with thread shutdown incomplete"
- << LL_ENDL;
- }
- }
-
- delete mRequest;
- mRequest = NULL;
-
- LLCore::HttpStatus status = LLCore::HttpRequest::destroyService();
- if (! status)
- {
- LL_WARNS("Cleanup") << "Failed to shutdown HTTP services, continuing. Reason: "
- << status.toString()
- << LL_ENDL;
- }
-}
-
-
-void CoreHttp::onCompleted(LLCore::HttpHandle, LLCore::HttpResponse *)
-{
- mStopped = true;
-}
-
-} // end anonymous namespace