summaryrefslogtreecommitdiff
path: root/indra/llcrashlogger
diff options
context:
space:
mode:
authorRider Linden <none@none>2015-04-30 13:12:09 -0700
committerRider Linden <none@none>2015-04-30 13:12:09 -0700
commitcd55655592b7518451d78b1ef229bce3316af420 (patch)
tree6d6158bd23ecf3bb662465fa10ebb5a1b8fb4789 /indra/llcrashlogger
parent82b671dadc52ae2caca9c5b2ad0f1110c15754af (diff)
Crash logger changes to LLCore::Http
Diffstat (limited to 'indra/llcrashlogger')
-rwxr-xr-xindra/llcrashlogger/CMakeLists.txt2
-rwxr-xr-xindra/llcrashlogger/llcrashlogger.cpp125
-rwxr-xr-xindra/llcrashlogger/llcrashlogger.h10
3 files changed, 109 insertions, 28 deletions
diff --git a/indra/llcrashlogger/CMakeLists.txt b/indra/llcrashlogger/CMakeLists.txt
index ba4e34d92b..c41e61c497 100755
--- a/indra/llcrashlogger/CMakeLists.txt
+++ b/indra/llcrashlogger/CMakeLists.txt
@@ -3,6 +3,7 @@
project(llcrashlogger)
include(00-Common)
+include(LLCoreHttp)
include(LLCommon)
include(LLMath)
include(LLMessage)
@@ -10,6 +11,7 @@ include(LLVFS)
include(LLXML)
include_directories(
+ ${LLCOREHTTP_INCLUDE_DIRS}
${LLCOMMON_INCLUDE_DIRS}
${LLMATH_INCLUDE_DIRS}
${LLMESSAGE_INCLUDE_DIRS}
diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp
index 7a97c16ea7..ec794ac478 100755
--- a/indra/llcrashlogger/llcrashlogger.cpp
+++ b/indra/llcrashlogger/llcrashlogger.cpp
@@ -40,38 +40,45 @@
#include "lldir.h"
#include "llfile.h"
#include "llsdserialize.h"
-#include "lliopipe.h"
-#include "llpumpio.h"
-#include "llhttpclient.h"
#include "llsdserialize.h"
#include "llproxy.h"
-
-LLPumpIO* gServicePump = NULL;
+#include "llcorehttputil.h"
+#include "llhttpsdhandler.h"
+#include "httpcommon.h"
+#include "httpresponse.h"
+
+#include <curl/curl.h>
+#include <openssl/crypto.h>
+
BOOL gBreak = false;
BOOL gSent = false;
-class LLCrashLoggerResponder : public LLHTTPClient::Responder
+int LLCrashLogger::ssl_mutex_count = 0;
+LLCoreInt::HttpMutex ** LLCrashLogger::ssl_mutex_list = NULL;
+
+class LLCrashLoggerHandler : public LLHttpSDHandler
{
- LOG_CLASS(LLCrashLoggerResponder);
+ LOG_CLASS(LLCrashLoggerHandler);
public:
- LLCrashLoggerResponder()
- {
- }
+ LLCrashLoggerHandler() {}
protected:
- virtual void httpFailure()
- {
- LL_WARNS() << dumpResponse() << LL_ENDL;
- gBreak = true;
- }
+ virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content);
+ virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status);
- virtual void httpSuccess()
- {
- gBreak = true;
- gSent = true;
- }
};
+void LLCrashLoggerHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content)
+{
+ gBreak = true;
+ gSent = true;
+}
+
+void LLCrashLoggerHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status)
+{
+ gBreak = true;
+}
+
LLCrashLogger::LLCrashLogger() :
mCrashBehavior(CRASH_BEHAVIOR_ALWAYS_SEND),
mCrashInPreviousExec(false),
@@ -389,14 +396,20 @@ bool LLCrashLogger::saveCrashBehaviorSetting(S32 crash_behavior)
bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg, int retries, int timeout)
{
+ LLCore::HttpRequest httpRequest;
+
gBreak = false;
for(int i = 0; i < retries; ++i)
{
updateApplication(llformat("%s, try %d...", msg.c_str(), i+1));
- LLHTTPClient::post(host, data, new LLCrashLoggerResponder(), timeout);
- while(!gBreak)
+
+ LLCoreHttpUtil::requestPostWithLLSD(&httpRequest, LLCore::HttpRequest::DEFAULT_POLICY_ID, 0,
+ host, data, NULL, NULL, new LLCrashLoggerHandler);
+
+ while(!gBreak)
{
updateApplication(); // No new message, just pump the IO
+ httpRequest.update(0L);
}
if(gSent)
{
@@ -510,8 +523,6 @@ bool LLCrashLogger::sendCrashLogs()
void LLCrashLogger::updateApplication(const std::string& message)
{
- gServicePump->pump();
- gServicePump->callback();
if (!message.empty()) LL_INFOS() << message << LL_ENDL;
}
@@ -576,16 +587,74 @@ bool LLCrashLogger::init()
return false;
}
- gServicePump = new LLPumpIO(gAPRPoolp);
- gServicePump->prime(gAPRPoolp);
- LLHTTPClient::setPump(*gServicePump);
-
+ init_curl();
+ LLCore::HttpRequest::createService();
+ LLCore::HttpRequest::startThread();
+
return true;
}
// For cleanup code common to all platforms.
void LLCrashLogger::commonCleanup()
{
+ term_curl();
LLError::logToFile(""); //close crashreport.log
LLProxy::cleanupClass();
}
+
+void LLCrashLogger::init_curl()
+{
+ curl_global_init(CURL_GLOBAL_ALL);
+
+ ssl_mutex_count = CRYPTO_num_locks();
+ if (ssl_mutex_count > 0)
+ {
+ ssl_mutex_list = new LLCoreInt::HttpMutex *[ssl_mutex_count];
+
+ for (int i(0); i < ssl_mutex_count; ++i)
+ {
+ ssl_mutex_list[i] = new LLCoreInt::HttpMutex;
+ }
+
+ CRYPTO_set_locking_callback(ssl_locking_callback);
+ CRYPTO_set_id_callback(ssl_thread_id_callback);
+ }
+}
+
+
+void LLCrashLogger::term_curl()
+{
+ CRYPTO_set_locking_callback(NULL);
+ for (int i(0); i < ssl_mutex_count; ++i)
+ {
+ delete ssl_mutex_list[i];
+ }
+ delete[] ssl_mutex_list;
+}
+
+
+unsigned long LLCrashLogger::ssl_thread_id_callback(void)
+{
+#if LL_WINDOWS
+ return (unsigned long)GetCurrentThread();
+#else
+ return (unsigned long)pthread_self();
+#endif
+}
+
+
+void LLCrashLogger::ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */)
+{
+ if (type >= 0 && type < ssl_mutex_count)
+ {
+ if (mode & CRYPTO_LOCK)
+ {
+ ssl_mutex_list[type]->lock();
+ }
+ else
+ {
+ ssl_mutex_list[type]->unlock();
+ }
+ }
+}
+
diff --git a/indra/llcrashlogger/llcrashlogger.h b/indra/llcrashlogger/llcrashlogger.h
index a06bf1d6ac..f5383daefc 100755
--- a/indra/llcrashlogger/llcrashlogger.h
+++ b/indra/llcrashlogger/llcrashlogger.h
@@ -34,6 +34,7 @@
#include "llsd.h"
#include "llcontrol.h"
#include "llcrashlock.h"
+#include "_mutex.h"
// Crash reporter behavior
const S32 CRASH_BEHAVIOR_ASK = 0;
@@ -66,6 +67,11 @@ public:
bool readMinidump(std::string minidump_path);
protected:
+ static void init_curl();
+ static void term_curl();
+ static unsigned long ssl_thread_id_callback(void);
+ static void ssl_locking_callback(int mode, int type, const char * file, int line);
+
S32 mCrashBehavior;
BOOL mCrashInPreviousExec;
std::map<std::string, std::string> mFileMap;
@@ -78,6 +84,10 @@ protected:
LLSD mDebugLog;
bool mSentCrashLogs;
LLCrashLock mKeyMaster;
+
+ static int ssl_mutex_count;
+ static LLCoreInt::HttpMutex ** ssl_mutex_list;
+
};
#endif //LLCRASHLOGGER_H