Backed out changeset 1e93024c9fec (bug 1164425) for bustage
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 20 May 2015 10:31:55 +0200
changeset 275322 bfa38d84133cbaec9fb9ec19f6062932e789d1f3
parent 275321 94ab7aa2012ffb4520cba847273ef94bae06d335
child 275323 2937d2a4267deff259354e3ab5cf433214144cb9
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1164425
milestone41.0a1
backs out1e93024c9fec38aec9b1be669e7e5b329baa492a
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
Backed out changeset 1e93024c9fec (bug 1164425) for bustage
dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
dom/bluetooth/bluedroid/BluetoothOppManager.cpp
dom/bluetooth/bluedroid/BluetoothSocket.cpp
dom/bluetooth/bluedroid/BluetoothSocket.h
dom/bluetooth/bluez/BluetoothSocket.cpp
dom/bluetooth/bluez/BluetoothSocket.h
ipc/bluetooth/BluetoothDaemonConnection.cpp
ipc/bluetooth/BluetoothDaemonConnection.h
ipc/unixsocket/ListenSocket.cpp
ipc/unixsocket/ListenSocket.h
ipc/unixsocket/SocketBase.cpp
ipc/unixsocket/SocketBase.h
ipc/unixsocket/StreamSocket.cpp
ipc/unixsocket/StreamSocket.h
--- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
@@ -1906,17 +1906,17 @@ BluetoothDaemonInterface::OnConnectSucce
       break;
     case CMD_CHANNEL:
       // Init, step 3: Listen for notification channel...
       if (!mNtfChannel) {
         mNtfChannel = new BluetoothDaemonChannel(this, NTF_CHANNEL, mProtocol);
       } else if (
         NS_WARN_IF(mNtfChannel->GetConnectionStatus() == SOCKET_CONNECTED)) {
         /* Notification channel should not be open; let's close it. */
-        mNtfChannel->Close();
+        mNtfChannel->CloseSocket();
       }
       if (!mListenSocket->Listen(mNtfChannel)) {
         OnConnectError(NTF_CHANNEL);
       }
       break;
     case NTF_CHANNEL: {
         nsRefPtr<BluetoothResultHandler> res = mResultHandlerQ.ElementAt(0);
         mResultHandlerQ.RemoveElementAt(0);
@@ -1937,17 +1937,17 @@ void
 BluetoothDaemonInterface::OnConnectError(enum Channel aChannel)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!mResultHandlerQ.IsEmpty());
 
   switch (aChannel) {
     case NTF_CHANNEL:
       // Close command channel
-      mCmdChannel->Close();
+      mCmdChannel->CloseSocket();
     case CMD_CHANNEL:
       // Stop daemon and close listen socket
       unused << NS_WARN_IF(property_set("ctl.stop", "bluetoothd"));
       mListenSocket->Close();
     case LISTEN_SOCKET:
       if (!mResultHandlerQ.IsEmpty()) {
         // Signal error to caller
         nsRefPtr<BluetoothResultHandler> res = mResultHandlerQ.ElementAt(0);
@@ -2115,17 +2115,17 @@ BluetoothDaemonInterface::Init(
 
   // Init, step 1: Listen for command channel... */
 
   if (!mCmdChannel) {
     mCmdChannel = new BluetoothDaemonChannel(this, CMD_CHANNEL, mProtocol);
   } else if (
     NS_WARN_IF(mCmdChannel->GetConnectionStatus() == SOCKET_CONNECTED)) {
     // Command channel should not be open; let's close it.
-    mCmdChannel->Close();
+    mCmdChannel->CloseSocket();
   }
 
   // The listen socket's name is generated with a random postfix. This
   // avoids naming collisions if we still have a listen socket from a
   // previously failed cleanup. It also makes it hard for malicious
   // external programs to capture the socket name or connect before
   // the daemon can do so. If no random postfix can be generated, we
   // simply use the base name as-is.
@@ -2177,17 +2177,17 @@ private:
     MOZ_ASSERT(mInterface->mProtocol);
 
     if (!mUnregisteredCoreModule) {
       mUnregisteredCoreModule = true;
       // Cleanup, step 2: Unregister Core module
       mInterface->mProtocol->UnregisterModuleCmd(0x01, this);
     } else {
       // Cleanup, step 3: Close command channel
-      mInterface->mCmdChannel->Close();
+      mInterface->mCmdChannel->CloseSocket();
     }
   }
 
   BluetoothDaemonInterface* mInterface;
   bool mUnregisteredCoreModule;
 };
 
 /*
--- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
@@ -178,17 +178,17 @@ public:
   CloseSocketTask(BluetoothSocket* aSocket) : mSocket(aSocket)
   {
     MOZ_ASSERT(aSocket);
   }
 
   void Run() override
   {
     MOZ_ASSERT(NS_IsMainThread());
-    mSocket->Close();
+    mSocket->CloseSocket();
   }
 
 private:
   nsRefPtr<BluetoothSocket> mSocket;
 };
 
 BluetoothOppManager::BluetoothOppManager() : mConnected(false)
                                            , mRemoteObexVersion(0)
@@ -277,17 +277,17 @@ BluetoothOppManager::Get()
 
 void
 BluetoothOppManager::ConnectInternal(const nsAString& aDeviceAddress)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // Stop listening because currently we only support one connection at a time.
   if (mServerSocket) {
-    mServerSocket->Close();
+    mServerSocket->CloseSocket();
     mServerSocket = nullptr;
   }
 
   mIsServer = false;
 
   BluetoothService* bs = BluetoothService::Get();
   if (!bs || sInShutdown || mSocket) {
     OnSocketConnectError(mSocket);
@@ -347,17 +347,17 @@ BluetoothOppManager::Listen()
   }
 
   /**
    * Restart server socket since its underlying fd becomes invalid when
    * BT stops; otherwise no more read events would be received even if
    * BT restarts.
    */
   if (mServerSocket) {
-    mServerSocket->Close();
+    mServerSocket->CloseSocket();
     mServerSocket = nullptr;
   }
 
   mServerSocket =
     new BluetoothSocket(this, BluetoothSocketType::RFCOMM, false, true);
 
   if (!mServerSocket->ListenSocket(NS_LITERAL_STRING("OBEX Object Push"),
                                    kObexObjectPush,
@@ -1547,17 +1547,17 @@ BluetoothOppManager::OnSocketDisconnect(
     Listen();
   }
 }
 
 void
 BluetoothOppManager::Disconnect(BluetoothProfileController* aController)
 {
   if (mSocket) {
-    mSocket->Close();
+    mSocket->CloseSocket();
   } else {
     BT_WARNING("%s: No ongoing file transfer to stop", __FUNCTION__);
   }
 }
 
 NS_IMPL_ISUPPORTS(BluetoothOppManager, nsIObserver)
 
 bool
--- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp
@@ -738,17 +738,17 @@ BluetoothSocket::SendSocketData(UnixSock
   XRE_GetIOMessageLoop()->PostTask(
     FROM_HERE,
     new SocketIOSendTask<DroidSocketImpl, UnixSocketIOBuffer>(mImpl, aBuffer));
 }
 
 // |SocketBase|
 
 void
-BluetoothSocket::Close()
+BluetoothSocket::CloseSocket()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(sBluetoothSocketInterface);
   if (!mImpl) {
     return;
   }
 
   // Stop any watching |SocketMessageWatcher|
--- a/dom/bluetooth/bluedroid/BluetoothSocket.h
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.h
@@ -58,17 +58,17 @@ public:
   // Methods for |DataSocket|
   //
 
   void SendSocketData(mozilla::ipc::UnixSocketIOBuffer* aBuffer) override;
 
   // Methods for |SocketBase|
   //
 
-  void Close() override;
+  void CloseSocket() override;
 
   void OnConnectSuccess() override;
   void OnConnectError() override;
   void OnDisconnect() override;
 
 private:
   BluetoothSocketObserver* mObserver;
   BluetoothSocketResultHandler* mCurrentRes;
--- a/dom/bluetooth/bluez/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluez/BluetoothSocket.cpp
@@ -715,17 +715,17 @@ BluetoothSocket::SendSocketData(UnixSock
   XRE_GetIOMessageLoop()->PostTask(
     FROM_HERE,
     new SocketIOSendTask<BluetoothSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
 }
 
 // |SocketBase|
 
 void
-BluetoothSocket::Close()
+BluetoothSocket::CloseSocket()
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (!mIO) {
     return;
   }
 
   mIO->CancelDelayedConnectTask();
 
--- a/dom/bluetooth/bluez/BluetoothSocket.h
+++ b/dom/bluetooth/bluez/BluetoothSocket.h
@@ -33,17 +33,17 @@ public:
   bool Connect(const nsAString& aDeviceAddress,
                const BluetoothUuid& aServiceUuid,
                int aChannel);
   bool Listen(const nsAString& aServiceName,
               const BluetoothUuid& aServiceUuid,
               int aChannel);
   inline void Disconnect()
   {
-    Close();
+    CloseSocket();
   }
 
   inline void GetAddress(nsAString& aDeviceAddress)
   {
     GetSocketAddr(aDeviceAddress);
   }
 
   /**
@@ -97,17 +97,17 @@ public:
   // Methods for |DataSocket|
   //
 
   void SendSocketData(mozilla::ipc::UnixSocketIOBuffer* aBuffer) override;
 
   // Methods for |SocketBase|
   //
 
-  void Close() override;
+  void CloseSocket() override;
 
   void OnConnectSuccess() override;
   void OnConnectError() override;
   void OnDisconnect() override;
 
 private:
   class BluetoothSocketIO;
   class ConnectTask;
--- a/ipc/bluetooth/BluetoothDaemonConnection.cpp
+++ b/ipc/bluetooth/BluetoothDaemonConnection.cpp
@@ -564,17 +564,17 @@ BluetoothDaemonConnection::SendSocketDat
     FROM_HERE,
     new SocketIOSendTask<BluetoothDaemonConnectionIO,
                          UnixSocketIOBuffer>(mIO, aBuffer));
 }
 
 // |SocketBase|
 
 void
-BluetoothDaemonConnection::Close()
+BluetoothDaemonConnection::CloseSocket()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!mIO) {
     CHROMIUM_LOG("Bluetooth daemon already disconnected!");
     return;
   }
 
--- a/ipc/bluetooth/BluetoothDaemonConnection.h
+++ b/ipc/bluetooth/BluetoothDaemonConnection.h
@@ -126,17 +126,17 @@ public:
   // Methods for |DataSocket|
   //
 
   void SendSocketData(UnixSocketIOBuffer* aBuffer) override;
 
   // Methods for |SocketBase|
   //
 
-  void Close() override;
+  void CloseSocket() override;
 
 protected:
 
   // Prepares an instance of |BluetoothDaemonConnection| in DISCONNECTED
   // state for accepting a connection. Subclasses implementing |GetIO|
   // need to call this method.
   ConnectionOrientedSocketIO*
     PrepareAccept(BluetoothDaemonPDUConsumer* aConsumer);
--- a/ipc/unixsocket/ListenSocket.cpp
+++ b/ipc/unixsocket/ListenSocket.cpp
@@ -309,16 +309,37 @@ ListenSocket::ListenSocket()
 : mIO(nullptr)
 { }
 
 ListenSocket::~ListenSocket()
 {
   MOZ_ASSERT(!mIO);
 }
 
+void
+ListenSocket::Close()
+{
+  MOZ_ASSERT(NS_IsMainThread());
+
+  if (!mIO) {
+    return;
+  }
+
+  // From this point on, we consider mIO as being deleted. We sever
+  // the relationship here so any future calls to listen or connect
+  // will create a new implementation.
+  mIO->ShutdownOnMainThread();
+
+  XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
+
+  mIO = nullptr;
+
+  NotifyDisconnect();
+}
+
 bool
 ListenSocket::Listen(UnixSocketConnector* aConnector,
                      ConnectionOrientedSocket* aCOSocket)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aConnector);
   MOZ_ASSERT(aCOSocket);
 
@@ -359,30 +380,15 @@ ListenSocket::GetSocketAddr(nsAString& a
     return;
   }
   mIO->GetSocketAddr(aAddrStr);
 }
 
 // |SocketBase|
 
 void
-ListenSocket::Close()
+ListenSocket::CloseSocket()
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!mIO) {
-    return;
-  }
-
-  // From this point on, we consider mIO as being deleted. We sever
-  // the relationship here so any future calls to listen or connect
-  // will create a new implementation.
-  mIO->ShutdownOnMainThread();
-
-  XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
-
-  mIO = nullptr;
-
-  NotifyDisconnect();
+  Close();
 }
 
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/unixsocket/ListenSocket.h
+++ b/ipc/unixsocket/ListenSocket.h
@@ -46,24 +46,30 @@ public:
    * @param aCOSocket The connection-oriented socket for handling the
    *                  accepted connection.
    *
    * @return true on listen started, false otherwise
    */
   bool Listen(ConnectionOrientedSocket* aCOSocket);
 
   /**
+   * Queues the internal representation of socket for deletion. Can be called
+   * from main thread.
+   */
+  void Close();
+
+  /**
    * Get the current sockaddr for the socket
    */
   void GetSocketAddr(nsAString& aAddrStr);
 
   // Methods for |SocketBase|
   //
 
-  void Close() override;
+  void CloseSocket() override;
 
 private:
   ListenSocketIO* mIO;
 };
 
 } // namespace ipc
 } // namepsace mozilla
 
--- a/ipc/unixsocket/SocketBase.cpp
+++ b/ipc/unixsocket/SocketBase.cpp
@@ -335,17 +335,17 @@ SocketIORequestClosingRunnable::Run()
     // Since we've already explicitly closed and the close
     // happened before this, this isn't really an error.
     return NS_OK;
   }
 
   SocketBase* socketBase = io->GetSocketBase();
   MOZ_ASSERT(socketBase);
 
-  socketBase->Close();
+  socketBase->CloseSocket();
 
   return NS_OK;
 }
 
 //
 // SocketIODeleteInstanceRunnable
 //
 
--- a/ipc/unixsocket/SocketBase.h
+++ b/ipc/unixsocket/SocketBase.h
@@ -253,17 +253,17 @@ public:
   SocketConnectionStatus GetConnectionStatus() const;
 
   int GetSuggestedConnectDelayMs() const;
 
   /**
    * Queues the internal representation of socket for deletion. Can be called
    * from main thread.
    */
-  virtual void Close() = 0;
+  virtual void CloseSocket() = 0;
 
   /**
    * Callback for socket connect/accept success. Called after connect/accept has
    * finished. Will be run on main thread, before any reads take place.
    */
   virtual void OnConnectSuccess() = 0;
 
   /**
--- a/ipc/unixsocket/StreamSocket.cpp
+++ b/ipc/unixsocket/StreamSocket.cpp
@@ -538,16 +538,39 @@ StreamSocket::SendSocketData(const nsACS
   }
 
   SendSocketData(new UnixSocketRawData(aStr.BeginReading(), aStr.Length()));
 
   return true;
 }
 
 void
+StreamSocket::Close()
+{
+  MOZ_ASSERT(NS_IsMainThread());
+
+  if (!mIO) {
+    return;
+  }
+
+  mIO->CancelDelayedConnectTask();
+
+  // From this point on, we consider mIO as being deleted.
+  // We sever the relationship here so any future calls to listen or connect
+  // will create a new implementation.
+  mIO->ShutdownOnMainThread();
+
+  XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
+
+  mIO = nullptr;
+
+  NotifyDisconnect();
+}
+
+void
 StreamSocket::GetSocketAddr(nsAString& aAddrStr)
 {
   aAddrStr.Truncate();
   if (!mIO || GetConnectionStatus() != SOCKET_CONNECTED) {
     NS_WARNING("No socket currently open!");
     return;
   }
   mIO->GetSocketAddr(aAddrStr);
@@ -612,33 +635,15 @@ StreamSocket::SendSocketData(UnixSocketI
   XRE_GetIOMessageLoop()->PostTask(
     FROM_HERE,
     new SocketIOSendTask<StreamSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
 }
 
 // |SocketBase|
 
 void
-StreamSocket::Close()
+StreamSocket::CloseSocket()
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!mIO) {
-    return;
-  }
-
-  mIO->CancelDelayedConnectTask();
-
-  // From this point on, we consider mIO as being deleted.
-  // We sever the relationship here so any future calls to listen or connect
-  // will create a new implementation.
-  mIO->ShutdownOnMainThread();
-
-  XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
-
-  mIO = nullptr;
-
-  NotifyDisconnect();
+  Close();
 }
 
-
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/unixsocket/StreamSocket.h
+++ b/ipc/unixsocket/StreamSocket.h
@@ -51,29 +51,35 @@ public:
    *
    * @return true on connect task started, false otherwise.
    */
   bool Connect(UnixSocketConnector* aConnector,
                const char* aAddress,
                int aDelayMs = 0);
 
   /**
+   * Queues the internal representation of socket for deletion. Can be called
+   * from main thread.
+   */
+  void Close();
+
+  /**
    * Get the current sockaddr for the socket
    */
   void GetSocketAddr(nsAString& aAddrStr);
 
   // Methods for |DataSocket|
   //
 
   void SendSocketData(UnixSocketIOBuffer* aBuffer) override;
 
   // Methods for |SocketBase|
   //
 
-  void Close() override;
+  void CloseSocket() override;
 
 protected:
   virtual ~StreamSocket();
 
   // Prepares an instance of |StreamSocket| in DISCONNECTED state
   // for accepting a connection. Subclasses implementing |GetIO|
   // need to call this method.
   ConnectionOrientedSocketIO* PrepareAccept(UnixSocketConnector* aConnector);