Bug 765158 - Remove naming of main thread, conflicts with process name on Linux, r=bsmedberg

This commit is contained in:
Honza Bambas 2012-07-11 20:20:17 +02:00
parent d08a526246
commit ca18892306
2 changed files with 19 additions and 4 deletions

View File

@ -10,7 +10,8 @@
#include "prprf.h"
#include "prio.h"
#include "prenv.h"
#include "plstr.h"
#include "plstr.h"
#include "nsThreadUtils.h"
namespace mozilla { namespace eventtracer {
@ -54,6 +55,22 @@ public:
char * mText2;
};
char * DupCurrentThreadName()
{
if (NS_IsMainThread())
return PL_strdup("Main Thread");
PRThread * currentThread = PR_GetCurrentThread();
const char * name = PR_GetThreadName(currentThread);
if (name)
return PL_strdup(name);
char buffer[128];
PR_snprintf(buffer, 127, "Nameless %p", currentThread);
return PL_strdup(buffer);
}
// An array of events, each thread keeps its own private instance
class RecordBatch {
public:
@ -62,7 +79,7 @@ public:
, mRecordsTail(mRecordsHead + kBatchSize)
, mNextRecord(mRecordsHead)
, mNextBatch(nsnull)
, mThreadNameCopy(PL_strdup(PR_GetThreadName(PR_GetCurrentThread())))
, mThreadNameCopy(DupCurrentThreadName())
{
MOZ_COUNT_CTOR(RecordBatch);
}

View File

@ -315,8 +315,6 @@ NS_InitXPCOM2(nsIServiceManager* *result,
{
NS_TIME_FUNCTION;
PR_SetCurrentThreadName("Main Thread");
nsresult rv = NS_OK;
// We are not shutting down