Bug 1538708 - Stop storing sockets in adb-client.js;r=ochameau a=pascalc
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 28 Mar 2019 15:21:21 +0000
changeset 526108 1796fcfc0b87f938ad8d1e7a584ca5fbf2c56ffe
parent 526107 661df9ccbd0de5eda56c3cf0a766c2ddcee3abbe
child 526109 9b56acdef604faeee96eb7cdb1369d8f2cf97042
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau, pascalc
bugs1538708
milestone67.0
Bug 1538708 - Stop storing sockets in adb-client.js;r=ochameau a=pascalc The client close() method is not used anywhere. Individual callers should be responsible for closing opened sockets if needed. Removing this method and the _sockets array, we no longer leak strings when calling adb.updateRuntimes() Differential Revision: https://phabricator.services.mozilla.com/D25213
devtools/shared/adb/adb-client.js
--- a/devtools/shared/adb/adb-client.js
+++ b/devtools/shared/adb/adb-client.js
@@ -11,18 +11,16 @@
 "use strict";
 
 const { AdbSocket } = require("./adb-socket");
 const { dumpn } = require("devtools/shared/DevToolsUtils");
 
 const OKAY = 0x59414b4f;
 const FAIL = 0x4c494146;
 
-const _sockets = [ ];
-
 // Return buffer, which differs between Gecko versions
 function getBuffer(packet) {
   return packet.buffer ? packet.buffer : packet;
 }
 
 // @param aPacket         The packet to get the length from.
 // @param aIgnoreResponse True if this packet has no OKAY/FAIL.
 // @return                A js object { length:...; data:... }
@@ -62,30 +60,21 @@ function createRequest(command) {
     length = "0" + length;
   }
 
   const encoder = new TextEncoder();
   dumpn("Created request: " + length + command);
   return encoder.encode(length + command);
 }
 
-function close() {
-  _sockets.forEach(function(s) {
-    s.close();
-  });
-}
-
 function connect() {
-  const tmp = new AdbSocket();
-  _sockets.push(tmp);
-  return tmp;
+  return new AdbSocket();
 }
 
 const client = {
   getBuffer,
   unpackPacket,
   checkResponse,
   createRequest,
   connect,
-  close,
 };
 
 module.exports = client;