Bug 1671577 - Use OtherPid() in AddProfilerMarker(). r=jld

Aside from its use in AddProfilerMarker(), after initialization mPeerPid
is only used on the IO thread, so the write to it does not hold the monitor.
This means that the read in AddProfilerMarker() can cause a race, even
though we hold the monitor. This method is only called when we hold
the monitor and everything is set up, so I think we can just use
mListener->OtherPid() to get the PID.

Differential Revision: https://phabricator.services.mozilla.com/D93810
This commit is contained in:
Andrew McCreight 2020-10-16 17:53:42 +00:00
Родитель 3fc0c60d52
Коммит 1425ce2012
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -2784,10 +2784,10 @@ void MessageChannel::DumpInterruptStack(const char* const pfx) const {
void MessageChannel::AddProfilerMarker(const IPC::Message& aMessage,
MessageDirection aDirection) {
mMonitor->AssertCurrentThreadOwns();
#ifdef MOZ_GECKO_PROFILER
if (profiler_feature_active(ProfilerFeature::IPCMessages)) {
// If mPeerPid is -1, messages are being sent to the current process.
int32_t pid = mPeerPid == -1 ? base::GetCurrentProcId() : mPeerPid;
int32_t pid = mListener->OtherPid();
PROFILER_ADD_MARKER_WITH_PAYLOAD(
"IPC", IPC, IPCMarkerPayload,
(pid, aMessage.seqno(), aMessage.type(), mSide, aDirection,