From 24a87517b403d9824454a7157f88def86ce9b1e3 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Wed, 20 May 2015 10:31:55 +0200 Subject: [PATCH] Backed out changeset 1e93024c9fec (bug 1164425) for bustage --- .../bluedroid/BluetoothDaemonInterface.cpp | 8 ++-- .../bluedroid/BluetoothOppManager.cpp | 8 ++-- dom/bluetooth/bluedroid/BluetoothSocket.cpp | 2 +- dom/bluetooth/bluedroid/BluetoothSocket.h | 2 +- dom/bluetooth/bluez/BluetoothSocket.cpp | 2 +- dom/bluetooth/bluez/BluetoothSocket.h | 4 +- ipc/bluetooth/BluetoothDaemonConnection.cpp | 2 +- ipc/bluetooth/BluetoothDaemonConnection.h | 2 +- ipc/unixsocket/ListenSocket.cpp | 40 ++++++++++------- ipc/unixsocket/ListenSocket.h | 8 +++- ipc/unixsocket/SocketBase.cpp | 2 +- ipc/unixsocket/SocketBase.h | 2 +- ipc/unixsocket/StreamSocket.cpp | 45 ++++++++++--------- ipc/unixsocket/StreamSocket.h | 8 +++- 14 files changed, 79 insertions(+), 56 deletions(-) diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp index 29c8aa819d5..5b20efd8117 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp @@ -1911,7 +1911,7 @@ BluetoothDaemonInterface::OnConnectSuccess(enum Channel aChannel) } 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); @@ -1942,7 +1942,7 @@ BluetoothDaemonInterface::OnConnectError(enum Channel aChannel) 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")); @@ -2120,7 +2120,7 @@ BluetoothDaemonInterface::Init( } 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 @@ -2182,7 +2182,7 @@ private: mInterface->mProtocol->UnregisterModuleCmd(0x01, this); } else { // Cleanup, step 3: Close command channel - mInterface->mCmdChannel->Close(); + mInterface->mCmdChannel->CloseSocket(); } } diff --git a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp index 0b969613af5..90f463c1d55 100644 --- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp @@ -183,7 +183,7 @@ public: void Run() override { MOZ_ASSERT(NS_IsMainThread()); - mSocket->Close(); + mSocket->CloseSocket(); } private: @@ -282,7 +282,7 @@ BluetoothOppManager::ConnectInternal(const nsAString& aDeviceAddress) // Stop listening because currently we only support one connection at a time. if (mServerSocket) { - mServerSocket->Close(); + mServerSocket->CloseSocket(); mServerSocket = nullptr; } @@ -352,7 +352,7 @@ BluetoothOppManager::Listen() * BT restarts. */ if (mServerSocket) { - mServerSocket->Close(); + mServerSocket->CloseSocket(); mServerSocket = nullptr; } @@ -1552,7 +1552,7 @@ void BluetoothOppManager::Disconnect(BluetoothProfileController* aController) { if (mSocket) { - mSocket->Close(); + mSocket->CloseSocket(); } else { BT_WARNING("%s: No ongoing file transfer to stop", __FUNCTION__); } diff --git a/dom/bluetooth/bluedroid/BluetoothSocket.cpp b/dom/bluetooth/bluedroid/BluetoothSocket.cpp index b33072d2575..62edd8d3af4 100644 --- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp +++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp @@ -743,7 +743,7 @@ BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer) // |SocketBase| void -BluetoothSocket::Close() +BluetoothSocket::CloseSocket() { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(sBluetoothSocketInterface); diff --git a/dom/bluetooth/bluedroid/BluetoothSocket.h b/dom/bluetooth/bluedroid/BluetoothSocket.h index 75443fb1f09..f6e8dc0cc24 100644 --- a/dom/bluetooth/bluedroid/BluetoothSocket.h +++ b/dom/bluetooth/bluedroid/BluetoothSocket.h @@ -63,7 +63,7 @@ public: // Methods for |SocketBase| // - void Close() override; + void CloseSocket() override; void OnConnectSuccess() override; void OnConnectError() override; diff --git a/dom/bluetooth/bluez/BluetoothSocket.cpp b/dom/bluetooth/bluez/BluetoothSocket.cpp index cc8a94a4e5a..02f573de6d9 100644 --- a/dom/bluetooth/bluez/BluetoothSocket.cpp +++ b/dom/bluetooth/bluez/BluetoothSocket.cpp @@ -720,7 +720,7 @@ BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer) // |SocketBase| void -BluetoothSocket::Close() +BluetoothSocket::CloseSocket() { MOZ_ASSERT(NS_IsMainThread()); if (!mIO) { diff --git a/dom/bluetooth/bluez/BluetoothSocket.h b/dom/bluetooth/bluez/BluetoothSocket.h index 6b646b30b91..9656ca8f000 100644 --- a/dom/bluetooth/bluez/BluetoothSocket.h +++ b/dom/bluetooth/bluez/BluetoothSocket.h @@ -38,7 +38,7 @@ public: int aChannel); inline void Disconnect() { - Close(); + CloseSocket(); } inline void GetAddress(nsAString& aDeviceAddress) @@ -102,7 +102,7 @@ public: // Methods for |SocketBase| // - void Close() override; + void CloseSocket() override; void OnConnectSuccess() override; void OnConnectError() override; diff --git a/ipc/bluetooth/BluetoothDaemonConnection.cpp b/ipc/bluetooth/BluetoothDaemonConnection.cpp index ac1c146b6d0..269be2e448c 100644 --- a/ipc/bluetooth/BluetoothDaemonConnection.cpp +++ b/ipc/bluetooth/BluetoothDaemonConnection.cpp @@ -569,7 +569,7 @@ BluetoothDaemonConnection::SendSocketData(UnixSocketIOBuffer* aBuffer) // |SocketBase| void -BluetoothDaemonConnection::Close() +BluetoothDaemonConnection::CloseSocket() { MOZ_ASSERT(NS_IsMainThread()); diff --git a/ipc/bluetooth/BluetoothDaemonConnection.h b/ipc/bluetooth/BluetoothDaemonConnection.h index ea26b68be16..bfb26eefcb6 100644 --- a/ipc/bluetooth/BluetoothDaemonConnection.h +++ b/ipc/bluetooth/BluetoothDaemonConnection.h @@ -131,7 +131,7 @@ public: // Methods for |SocketBase| // - void Close() override; + void CloseSocket() override; protected: diff --git a/ipc/unixsocket/ListenSocket.cpp b/ipc/unixsocket/ListenSocket.cpp index b49bb07b6d1..62cb76fba54 100644 --- a/ipc/unixsocket/ListenSocket.cpp +++ b/ipc/unixsocket/ListenSocket.cpp @@ -314,6 +314,27 @@ 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) @@ -364,24 +385,9 @@ ListenSocket::GetSocketAddr(nsAString& 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 diff --git a/ipc/unixsocket/ListenSocket.h b/ipc/unixsocket/ListenSocket.h index 77f0aae813a..f3422f704c5 100644 --- a/ipc/unixsocket/ListenSocket.h +++ b/ipc/unixsocket/ListenSocket.h @@ -50,6 +50,12 @@ public: */ 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 */ @@ -58,7 +64,7 @@ public: // Methods for |SocketBase| // - void Close() override; + void CloseSocket() override; private: ListenSocketIO* mIO; diff --git a/ipc/unixsocket/SocketBase.cpp b/ipc/unixsocket/SocketBase.cpp index 491c4638504..df9bd6f92cd 100644 --- a/ipc/unixsocket/SocketBase.cpp +++ b/ipc/unixsocket/SocketBase.cpp @@ -340,7 +340,7 @@ SocketIORequestClosingRunnable::Run() SocketBase* socketBase = io->GetSocketBase(); MOZ_ASSERT(socketBase); - socketBase->Close(); + socketBase->CloseSocket(); return NS_OK; } diff --git a/ipc/unixsocket/SocketBase.h b/ipc/unixsocket/SocketBase.h index 3c55f426ab3..9d8793b2dcf 100644 --- a/ipc/unixsocket/SocketBase.h +++ b/ipc/unixsocket/SocketBase.h @@ -258,7 +258,7 @@ public: * 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 diff --git a/ipc/unixsocket/StreamSocket.cpp b/ipc/unixsocket/StreamSocket.cpp index cd584e037bb..79b8471efc6 100644 --- a/ipc/unixsocket/StreamSocket.cpp +++ b/ipc/unixsocket/StreamSocket.cpp @@ -542,6 +542,29 @@ StreamSocket::SendSocketData(const nsACString& aStr) 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) { @@ -617,28 +640,10 @@ StreamSocket::SendSocketData(UnixSocketIOBuffer* 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 diff --git a/ipc/unixsocket/StreamSocket.h b/ipc/unixsocket/StreamSocket.h index 02f07118512..e3dd403a20f 100644 --- a/ipc/unixsocket/StreamSocket.h +++ b/ipc/unixsocket/StreamSocket.h @@ -55,6 +55,12 @@ public: 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 */ @@ -68,7 +74,7 @@ public: // Methods for |SocketBase| // - void Close() override; + void CloseSocket() override; protected: virtual ~StreamSocket();