aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/llerror.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llcommon/llerror.cpp')
-rw-r--r--linden/indra/llcommon/llerror.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llerror.cpp b/linden/indra/llcommon/llerror.cpp
index 5e520af..a0e42c1 100644
--- a/linden/indra/llcommon/llerror.cpp
+++ b/linden/indra/llcommon/llerror.cpp
@@ -1242,9 +1242,62 @@ namespace LLError
1242 char** LLCallStacks::sBuffer = NULL ; 1242 char** LLCallStacks::sBuffer = NULL ;
1243 S32 LLCallStacks::sIndex = 0 ; 1243 S32 LLCallStacks::sIndex = 0 ;
1244 1244
1245 class CallStacksLogLock
1246 {
1247 public:
1248 CallStacksLogLock();
1249 ~CallStacksLogLock();
1250 bool ok() const { return mOK; }
1251 private:
1252 bool mLocked;
1253 bool mOK;
1254 };
1255
1256 CallStacksLogLock::CallStacksLogLock()
1257 : mLocked(false), mOK(false)
1258 {
1259 if (!gCallStacksLogMutexp)
1260 {
1261 mOK = true;
1262 return;
1263 }
1264
1265 const int MAX_RETRIES = 5;
1266 for (int attempts = 0; attempts < MAX_RETRIES; ++attempts)
1267 {
1268 apr_status_t s = apr_thread_mutex_trylock(gCallStacksLogMutexp);
1269 if (!APR_STATUS_IS_EBUSY(s))
1270 {
1271 mLocked = true;
1272 mOK = true;
1273 return;
1274 }
1275
1276 ms_sleep(1);
1277 }
1278
1279 // We're hosed, we can't get the mutex. Blah.
1280 std::cerr << "CallStacksLogLock::CallStacksLogLock: failed to get mutex for log"
1281 << std::endl;
1282 }
1283
1284 CallStacksLogLock::~CallStacksLogLock()
1285 {
1286 if (mLocked)
1287 {
1288 apr_thread_mutex_unlock(gCallStacksLogMutexp);
1289 }
1290 }
1291
1245 //static 1292 //static
1246 void LLCallStacks::push(const char* function, const int line) 1293 void LLCallStacks::push(const char* function, const int line)
1247 { 1294 {
1295 CallStacksLogLock lock;
1296 if (!lock.ok())
1297 {
1298 return;
1299 }
1300
1248 if(!sBuffer) 1301 if(!sBuffer)
1249 { 1302 {
1250 sBuffer = new char*[512] ; 1303 sBuffer = new char*[512] ;
@@ -1280,6 +1333,12 @@ namespace LLError
1280 //static 1333 //static
1281 void LLCallStacks::end(std::ostringstream* _out) 1334 void LLCallStacks::end(std::ostringstream* _out)
1282 { 1335 {
1336 CallStacksLogLock lock;
1337 if (!lock.ok())
1338 {
1339 return;
1340 }
1341
1283 if(!sBuffer) 1342 if(!sBuffer)
1284 { 1343 {
1285 sBuffer = new char*[512] ; 1344 sBuffer = new char*[512] ;
@@ -1302,6 +1361,12 @@ namespace LLError
1302 //static 1361 //static
1303 void LLCallStacks::print() 1362 void LLCallStacks::print()
1304 { 1363 {
1364 CallStacksLogLock lock;
1365 if (!lock.ok())
1366 {
1367 return;
1368 }
1369
1305 if(sIndex > 0) 1370 if(sIndex > 0)
1306 { 1371 {
1307 llinfos << " ************* PRINT OUT LL CALL STACKS ************* " << llendl ; 1372 llinfos << " ************* PRINT OUT LL CALL STACKS ************* " << llendl ;