Bug 1050509: Shut down the KeyStore socket during system shutdown to avoid leaks. r=tdz
authorKyle Huey <khuey@kylehuey.com>
Fri, 08 Aug 2014 11:11:36 -0700
changeset 198570 b7435ce126ab74e4aba8d140fce96344b3099b6a
parent 198569 65cc380f19118f55797e1018d9068b54aa5313c0
child 198571 92f37514960af308e425669346b677280d8ec2a6
push id27276
push userryanvm@gmail.com
push dateFri, 08 Aug 2014 20:15:27 +0000
treeherdermozilla-central@08bfcc7c6789 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstdz
bugs1050509
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1050509: Shut down the KeyStore socket during system shutdown to avoid leaks. r=tdz
dom/system/gonk/SystemWorkerManager.cpp
ipc/keystore/KeyStore.cpp
ipc/keystore/KeyStore.h
--- a/dom/system/gonk/SystemWorkerManager.cpp
+++ b/dom/system/gonk/SystemWorkerManager.cpp
@@ -124,16 +124,21 @@ SystemWorkerManager::Shutdown()
 
   nsCOMPtr<nsIWifi> wifi(do_QueryInterface(mWifiWorker));
   if (wifi) {
     wifi->Shutdown();
     wifi = nullptr;
   }
   mWifiWorker = nullptr;
 
+  if (mKeyStore) {
+    mKeyStore->CloseSocket();
+    mKeyStore = nullptr;
+  }
+
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (obs) {
     obs->RemoveObserver(this, WORKERS_SHUTDOWN_TOPIC);
   }
 }
 
 // static
 already_AddRefed<SystemWorkerManager>
--- a/ipc/keystore/KeyStore.cpp
+++ b/ipc/keystore/KeyStore.cpp
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set sw=4 ts=8 et ft=cpp: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <fcntl.h>
 #include <limits.h>
 #include <pwd.h>
@@ -354,20 +354,26 @@ KeyStoreConnector::GetSocketAddr(const s
                                  nsAString& aAddrStr)
 {
   // Unused.
   MOZ_CRASH("This should never be called!");
 }
 
 KeyStore::KeyStore()
 {
+  MOZ_COUNT_CTOR(KeyStore);
   ::startKeyStoreService();
   Listen();
 }
 
+KeyStore::~KeyStore()
+{
+  MOZ_COUNT_DTOR(KeyStore);
+}
+
 void
 KeyStore::Shutdown()
 {
   mShutdown = true;
   CloseSocket();
 }
 
 void
--- a/ipc/keystore/KeyStore.h
+++ b/ipc/keystore/KeyStore.h
@@ -93,21 +93,22 @@ public:
   virtual void GetSocketAddr(const sockaddr_any& aAddr,
                              nsAString& aAddrStr);
 };
 
 class KeyStore : public mozilla::ipc::UnixSocketConsumer
 {
 public:
   KeyStore();
-  virtual ~KeyStore() {}
 
   void Shutdown();
 
 private:
+  virtual ~KeyStore();
+
   virtual void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage);
 
   virtual void OnConnectSuccess();
   virtual void OnConnectError();
   virtual void OnDisconnect();
 
   struct {
     ProtocolHandlerState          state;