Bug 1268938 - Use the name of the original message in Send for reply telemetry. r=billm a=ritu
authorAndrew McCreight <continuation@gmail.com>
Mon, 02 May 2016 20:37:40 -0700
changeset 326181 3a218b10e323f35b968500349f6a557903bf09bb
parent 326180 3d7688da70b61b7caca228b80aeeb0a629e5ed13
child 326182 655bc3d29ea231ba06117f832e95c69e8bca025a
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm, ritu
bugs1268938
milestone47.0
Bug 1268938 - Use the name of the original message in Send for reply telemetry. r=billm a=ritu aReply usually won't have a name properly set, but aMsg does. To avoid accessing aMsg after it dies, copy the pointer to the name.
ipc/glue/MessageChannel.cpp
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -1136,16 +1136,19 @@ MessageChannel::Send(Message* aMsg, Mess
     int32_t transaction = nest ? stackTop->TransactionID() : seqno;
     msg->set_transaction_id(transaction);
 
     bool handleWindowsMessages = mListener->HandleWindowsMessages(*aMsg);
     AutoEnterTransaction transact(this, seqno, transaction, prio);
 
     IPC_LOG("Send seqno=%d, xid=%d", seqno, transaction);
 
+    // msg will be destroyed soon, but name() is not owned by msg.
+    const char* msgName = msg->name();
+
     mLink->SendMessage(msg.forget());
 
     while (true) {
         MOZ_RELEASE_ASSERT(!transact.IsCanceled());
         ProcessPendingRequests(transact);
         if (transact.IsComplete()) {
             break;
         }
@@ -1224,17 +1227,17 @@ MessageChannel::Send(Message* aMsg, Mess
     MOZ_RELEASE_ASSERT(!reply->is_reply_error());
     MOZ_RELEASE_ASSERT(reply->seqno() == seqno);
     MOZ_RELEASE_ASSERT(reply->type() == replyType, "wrong reply type");
     MOZ_RELEASE_ASSERT(reply->is_sync());
 
     *aReply = Move(*reply);
     if (aReply->capacity() >= kMinTelemetryMessageSize) {
         Telemetry::Accumulate(Telemetry::IPC_REPLY_SIZE,
-                              nsDependentCString(aReply->name()), aReply->capacity());
+                              nsDependentCString(msgName), aReply->capacity());
     }
     return true;
 }
 
 bool
 MessageChannel::Call(Message* aMsg, Message* aReply)
 {
     nsAutoPtr<Message> msg(aMsg);