Bug 1309823 - Forget file descriptors before starting actor destruction. r=billm, a=lizzard
authorBen Kelly <ben@wanderview.com>
Fri, 14 Oct 2016 08:27:28 +0200
changeset 428852 752c1320cca5a9757d0d159a3c8d303160aae0b0
parent 428851 af995f34ee2e5342db8f33ae3d2b9f164ad6273e
child 428853 c03e51cec3b5f6b8821687c8db8be309727d5470
push id33416
push userpaul@paul.cx
push dateMon, 24 Oct 2016 16:26:20 +0000
reviewersbillm, lizzard
bugs1309823
milestone50.0
Bug 1309823 - Forget file descriptors before starting actor destruction. r=billm, a=lizzard
ipc/glue/IPCStreamUtils.cpp
--- a/ipc/glue/IPCStreamUtils.cpp
+++ b/ipc/glue/IPCStreamUtils.cpp
@@ -168,42 +168,42 @@ CleanupIPCStream(IPCStream& aValue, bool
         OptionalFileDescriptorSet::TPFileDescriptorSetChild) {
 
       AutoTArray<FileDescriptor, 4> fds;
 
       auto fdSetActor = static_cast<FileDescriptorSetChild*>(
         streamWithFds.optionalFds().get_PFileDescriptorSetChild());
       MOZ_ASSERT(fdSetActor);
 
-      if (!aConsumedByIPC) {
-        Unused << fdSetActor->Send__delete__(fdSetActor);
-      }
-
       // FileDescriptorSet doesn't clear its fds in its ActorDestroy, so we
       // unconditionally forget them here.  The fds themselves are auto-closed in
       // ~FileDescriptor since they originated in this process.
       fdSetActor->ForgetFileDescriptors(fds);
 
+      if (!aConsumedByIPC) {
+        Unused << fdSetActor->Send__delete__(fdSetActor);
+      }
+
     } else if (streamWithFds.optionalFds().type() ==
                OptionalFileDescriptorSet::TPFileDescriptorSetParent) {
 
       AutoTArray<FileDescriptor, 4> fds;
 
       auto fdSetActor = static_cast<FileDescriptorSetParent*>(
         streamWithFds.optionalFds().get_PFileDescriptorSetParent());
       MOZ_ASSERT(fdSetActor);
 
-      if (!aConsumedByIPC) {
-        Unused << fdSetActor->Send__delete__(fdSetActor);
-      }
-
       // FileDescriptorSet doesn't clear its fds in its ActorDestroy, so we
       // unconditionally forget them here.  The fds themselves are auto-closed in
       // ~FileDescriptor since they originated in this process.
       fdSetActor->ForgetFileDescriptors(fds);
+
+      if (!aConsumedByIPC) {
+        Unused << fdSetActor->Send__delete__(fdSetActor);
+      }
     }
 
     return;
   }
 
   MOZ_ASSERT(aValue.type() == IPCStream::TPSendStreamChild);
 
   auto sendStream =