From 8dd4e3ff13ecf2d99cae2cd89d12e899a7c18d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Figui=C3=A8re?= Date: Tue, 26 Mar 2013 21:07:50 -0400 Subject: [PATCH] Backout 96f2990b1124 (bug 840612) due to orange on Mn. CLOSED TREE --- netwerk/base/public/nsASocketHandler.h | 9 ---- netwerk/base/public/nsIServerSocket.idl | 44 +------------------ netwerk/base/src/nsServerSocket.cpp | 17 +------ netwerk/base/src/nsServerSocket.h | 2 - .../base/src/nsSocketTransportService2.cpp | 10 +---- .../components/marionettecomponent.js | 5 +-- testing/marionette/marionette-actors.js | 4 ++ .../devtools/debugger/server/dbg-server.js | 8 ++-- 8 files changed, 15 insertions(+), 84 deletions(-) diff --git a/netwerk/base/public/nsASocketHandler.h b/netwerk/base/public/nsASocketHandler.h index 56f01aaa31b2..7af6aa20e63a 100644 --- a/netwerk/base/public/nsASocketHandler.h +++ b/netwerk/base/public/nsASocketHandler.h @@ -71,15 +71,6 @@ public: // virtual void IsLocal(bool *aIsLocal) = 0; - // - // called to determine if this socket should not be terminated when Gecko - // is turned offline. This is mostly useful for the debugging server - // socket. - // - virtual void KeepWhenOffline(bool *aKeepWhenOffline) - { - *aKeepWhenOffline = false; - } // // returns the number of bytes sent/transmitted over the socket diff --git a/netwerk/base/public/nsIServerSocket.idl b/netwerk/base/public/nsIServerSocket.idl index 072eaceafbe1..84e4799237ce 100644 --- a/netwerk/base/public/nsIServerSocket.idl +++ b/netwerk/base/public/nsIServerSocket.idl @@ -11,31 +11,14 @@ interface nsISocketTransport; native PRNetAddr(union PRNetAddr); [ptr] native PRNetAddrPtr(union PRNetAddr); -typedef unsigned long nsServerSocketFlag; - /** * nsIServerSocket * * An interface to a server socket that can accept incoming connections. */ -[scriptable, uuid(0df6a0e2-a6b1-4d4c-b30d-f2cb093444e3)] +[scriptable, uuid(a5b64be0-d563-46bb-ae95-132e46fcd42f)] interface nsIServerSocket : nsISupports { - /** - * @name Server Socket Flags - * These flags define various socket options. - * @{ - */ - /// The server socket will only respond to connections on the - /// local loopback interface. Otherwise, it will accept connections - /// from any interface. To specify a particular network interface, - /// use initWithAddress. - const nsServerSocketFlag LoopbackOnly = 0x00000001; - /// The server socket will not be closed when Gecko is set - /// offline. - const nsServerSocketFlag KeepWhenOffline = 0x00000002; - /** @} */ - /** * init * @@ -54,30 +37,7 @@ interface nsIServerSocket : nsISupports * This parameter may be silently limited by the operating system. * Pass -1 to use the default value. */ - void init(in long aPort, - in boolean aLoopbackOnly, - in long aBackLog); - - /** - * initSpecialConnection - * - * This method initializes a server socket and offers the ability to have - * that socket not get terminated if Gecko is set offline. - * - * @param aPort - * The port of the server socket. Pass -1 to indicate no preference, - * and a port will be selected automatically. - * @param aFlags - * Flags for the socket. - * @param aBackLog - * The maximum length the queue of pending connections may grow to. - * This parameter may be silently limited by the operating system. - * Pass -1 to use the default value. - */ - void initSpecialConnection(in long aPort, - in nsServerSocketFlag aFlags, - in long aBackLog); - + void init(in long aPort, in boolean aLoopbackOnly, in long aBackLog); /** * initWithAddress diff --git a/netwerk/base/src/nsServerSocket.cpp b/netwerk/base/src/nsServerSocket.cpp index 909968ba42c5..7c72011eb999 100644 --- a/netwerk/base/src/nsServerSocket.cpp +++ b/netwerk/base/src/nsServerSocket.cpp @@ -45,7 +45,6 @@ nsServerSocket::nsServerSocket() : mLock("nsServerSocket.mLock") , mFD(nullptr) , mAttached(false) - , mKeepWhenOffline(false) { // we want to be able to access the STS directly, and it may not have been // constructed yet. the STS constructor sets gSocketTransportService. @@ -234,12 +233,6 @@ nsServerSocket::IsLocal(bool *aIsLocal) *aIsLocal = PR_IsNetAddrType(&mAddr, PR_IpAddrLoopback); } -void -nsServerSocket::KeepWhenOffline(bool *aKeepWhenOffline) -{ - *aKeepWhenOffline = mKeepWhenOffline; -} - //----------------------------------------------------------------------------- // nsServerSocket::nsISupports //----------------------------------------------------------------------------- @@ -253,26 +246,18 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsServerSocket, nsIServerSocket) NS_IMETHODIMP nsServerSocket::Init(int32_t aPort, bool aLoopbackOnly, int32_t aBackLog) -{ - return InitSpecialConnection(aPort, aLoopbackOnly ? LoopbackOnly : 0, aBackLog); -} - -NS_IMETHODIMP -nsServerSocket::InitSpecialConnection(int32_t aPort, nsServerSocketFlag aFlags, - int32_t aBackLog) { PRNetAddrValue val; PRNetAddr addr; if (aPort < 0) aPort = 0; - if (aFlags & nsIServerSocket::LoopbackOnly) + if (aLoopbackOnly) val = PR_IpAddrLoopback; else val = PR_IpAddrAny; PR_SetNetAddr(val, PR_AF_INET, aPort, &addr); - mKeepWhenOffline = ((aFlags & nsIServerSocket::KeepWhenOffline) != 0); return InitWithAddress(&addr, aBackLog); } diff --git a/netwerk/base/src/nsServerSocket.h b/netwerk/base/src/nsServerSocket.h index 43735e0ea7e0..4018f135004a 100644 --- a/netwerk/base/src/nsServerSocket.h +++ b/netwerk/base/src/nsServerSocket.h @@ -23,7 +23,6 @@ public: virtual void OnSocketReady(PRFileDesc *fd, int16_t outFlags); virtual void OnSocketDetached(PRFileDesc *fd); virtual void IsLocal(bool *aIsLocal); - virtual void KeepWhenOffline(bool *aKeepWhenOffline); virtual uint64_t ByteCountSent() { return 0; } virtual uint64_t ByteCountReceived() { return 0; } @@ -46,7 +45,6 @@ private: nsCOMPtr mListener; nsCOMPtr mListenerTarget; bool mAttached; - bool mKeepWhenOffline; }; //----------------------------------------------------------------------------- diff --git a/netwerk/base/src/nsSocketTransportService2.cpp b/netwerk/base/src/nsSocketTransportService2.cpp index 2b902e8a8e71..348d82258d82 100644 --- a/netwerk/base/src/nsSocketTransportService2.cpp +++ b/netwerk/base/src/nsSocketTransportService2.cpp @@ -693,21 +693,15 @@ nsSocketTransportService::Reset(bool aGuardLocals) bool isGuarded; for (i = mActiveCount - 1; i >= 0; --i) { isGuarded = false; - if (aGuardLocals) { + if (aGuardLocals) mActiveList[i].mHandler->IsLocal(&isGuarded); - if (!isGuarded) - mActiveList[i].mHandler->KeepWhenOffline(&isGuarded); - } if (!isGuarded) DetachSocket(mActiveList, &mActiveList[i]); } for (i = mIdleCount - 1; i >= 0; --i) { isGuarded = false; - if (aGuardLocals) { + if (aGuardLocals) mIdleList[i].mHandler->IsLocal(&isGuarded); - if (!isGuarded) - mIdleList[i].mHandler->KeepWhenOffline(&isGuarded); - } if (!isGuarded) DetachSocket(mIdleList, &mIdleList[i]); } diff --git a/testing/marionette/components/marionettecomponent.js b/testing/marionette/components/marionettecomponent.js index 0206326c7f1a..36526b35f658 100644 --- a/testing/marionette/components/marionettecomponent.js +++ b/testing/marionette/components/marionettecomponent.js @@ -13,7 +13,7 @@ const MARIONETTE_FORCELOCAL_PREF = 'marionette.force-local'; const ServerSocket = CC("@mozilla.org/network/server-socket;1", "nsIServerSocket", - "initSpecialConnection"); + "init"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); @@ -89,10 +89,9 @@ MarionetteComponent.prototype = { if (!marionette_forcelocal) { // See bug 800138. Because the first socket that opens with // force-local=false fails, we open a dummy socket that will fail. - // keepWhenOffline=true so that it still work when offline (local). // This allows the following attempt by Marionette to open a socket // to succeed. - let insaneSacrificialGoat = new ServerSocket(666, Ci.nsIServerSocket.KeepWhenOffline, 4); + let insaneSacrificialGoat = new ServerSocket(666, false, 4); insaneSacrificialGoat.asyncListen(this); } diff --git a/testing/marionette/marionette-actors.js b/testing/marionette/marionette-actors.js index f301ba83d1a3..f1be88058b2b 100644 --- a/testing/marionette/marionette-actors.js +++ b/testing/marionette/marionette-actors.js @@ -41,6 +41,10 @@ Cu.import("resource://gre/modules/services-common/log4moz.js"); let logger = Log4Moz.repository.getLogger("Marionette"); logger.info('marionette-actors.js loaded'); +Services.prefs.setBoolPref("network.gonk.manage-offline-status", false); +Services.io.manageOfflineStatus = false; +Services.io.offline = false; + // This is used to prevent newSession from returning before the telephony // API's are ready; see bug 792647. This assumes that marionette-actors.js // will be loaded before the 'system-message-listener-ready' message diff --git a/toolkit/devtools/debugger/server/dbg-server.js b/toolkit/devtools/debugger/server/dbg-server.js index d7a89b8202a4..f3bde2d0c021 100644 --- a/toolkit/devtools/debugger/server/dbg-server.js +++ b/toolkit/devtools/debugger/server/dbg-server.js @@ -55,7 +55,7 @@ loadSubScript.call(this, "chrome://global/content/devtools/dbg-transport.js"); // XPCOM constructors const ServerSocket = CC("@mozilla.org/network/server-socket;1", "nsIServerSocket", - "initSpecialConnection"); + "init"); /*** * Public API @@ -212,14 +212,14 @@ var DebuggerServer = { return true; } - let flags = Ci.nsIServerSocket.KeepWhenOffline; + let localOnly = false; // A preference setting can force binding on the loopback interface. if (Services.prefs.getBoolPref("devtools.debugger.force-local")) { - flags |= Ci.nsIServerSocket.LoopbackOnly; + localOnly = true; } try { - let socket = new ServerSocket(aPort, flags, 4); + let socket = new ServerSocket(aPort, localOnly, 4); socket.asyncListen(this); this._listener = socket; } catch (e) {