Bug 1541282 - Use native call in NS_SetCurrentThreadName() on Android r=froydnj

PR_SetCurrentThreadName() is broken on Android (Bug 1541216).
In order to work around this issue, NS_SetCurrentThreadName() will
call  prctl(PR_SET_NAME, name) until the underlying nspr can be
fixed.

Differential Revision: https://phabricator.services.mozilla.com/D25891

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Randall E. Barker 2019-04-03 00:23:22 +00:00
parent 2f6cd63d92
commit 1d15aad0e5

View File

@ -28,6 +28,10 @@
# include <sys/resource.h>
#endif
#if defined(ANDROID)
# include <sys/prctl.h>
#endif
using namespace mozilla;
#ifndef XPCOM_GLUE_AVOID_NSPR
@ -483,7 +487,12 @@ bool NS_ProcessNextEvent(nsIThread* aThread, bool aMayWait) {
}
void NS_SetCurrentThreadName(const char* aName) {
#if defined(ANDROID)
// Workaround for Bug 1541216 - PR_SetCurrentThreadName() Fails to set the thread name on Android.
prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(aName));
#else
PR_SetCurrentThreadName(aName);
#endif
CrashReporter::SetCurrentThreadName(aName);
}