Bug 1033079 - Part 1: Server style cleanup. r=past

This commit is contained in:
J. Ryan Stinnett 2014-07-02 15:47:00 -04:00
parent ad15f192df
commit f70d75e64e

View File

@ -439,11 +439,11 @@ var DebuggerServer = {
/** /**
* Listens on the given port or socket file for remote debugger connections. * Listens on the given port or socket file for remote debugger connections.
* *
* @param aPortOrPath int, string * @param portOrPath int, string
* If given an integer, the port to listen on. * If given an integer, the port to listen on.
* Otherwise, the path to the unix socket domain file to listen on. * Otherwise, the path to the unix socket domain file to listen on.
*/ */
openListener: function DS_openListener(aPortOrPath) { openListener: function(portOrPath) {
if (!Services.prefs.getBoolPref("devtools.debugger.remote-enabled")) { if (!Services.prefs.getBoolPref("devtools.debugger.remote-enabled")) {
return false; return false;
} }
@ -463,11 +463,11 @@ var DebuggerServer = {
try { try {
let backlog = 4; let backlog = 4;
let socket; let socket;
let port = Number(aPortOrPath); let port = Number(portOrPath);
if (port) { if (port) {
socket = new ServerSocket(port, flags, backlog); socket = new ServerSocket(port, flags, backlog);
} else { } else {
let file = nsFile(aPortOrPath); let file = nsFile(portOrPath);
if (file.exists()) if (file.exists())
file.remove(false); file.remove(false);
socket = new UnixDomainServerSocket(file, parseInt("666", 8), backlog); socket = new UnixDomainServerSocket(file, parseInt("666", 8), backlog);
@ -475,7 +475,7 @@ var DebuggerServer = {
socket.asyncListen(this); socket.asyncListen(this);
this._listener = socket; this._listener = socket;
} catch (e) { } catch (e) {
dumpn("Could not start debugging listener on '" + aPortOrPath + "': " + e); dumpn("Could not start debugging listener on '" + portOrPath + "': " + e);
throw Cr.NS_ERROR_NOT_AVAILABLE; throw Cr.NS_ERROR_NOT_AVAILABLE;
} }
this._socketConnections++; this._socketConnections++;
@ -486,18 +486,18 @@ var DebuggerServer = {
/** /**
* Close a previously-opened TCP listener. * Close a previously-opened TCP listener.
* *
* @param aForce boolean [optional] * @param force boolean [optional]
* If set to true, then the socket will be closed, regardless of the * If set to true, then the socket will be closed, regardless of the
* number of open connections. * number of open connections.
*/ */
closeListener: function DS_closeListener(aForce) { closeListener: function(force) {
if (!this._listener || this._socketConnections == 0) { if (!this._listener || this._socketConnections == 0) {
return false; return false;
} }
// Only close the listener when the last connection is closed, or if the // Only close the listener when the last connection is closed, or if the
// aForce flag is passed. // force flag is passed.
if (--this._socketConnections == 0 || aForce) { if (--this._socketConnections == 0 || force) {
this._listener.close(); this._listener.close();
this._listener = null; this._listener = null;
this._socketConnections = 0; this._socketConnections = 0;