Bug 1016785 - Use more filtering to tell DIAL devices apart r=wesj
authorMark Finkle <mfinkle@mozilla.com>
Wed, 04 Jun 2014 15:25:09 -0400
changeset 205806 e160cbe83f39d9cd6bacadd1f0a44ce54f1de0d0
parent 205805 1d19acb6394d08e14e714773ea469651a527fb9b
child 205807 52068b669c2af0023292655c64a568a63e94608f
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs1016785
milestone32.0a1
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
Bug 1016785 - Use more filtering to tell DIAL devices apart r=wesj
mobile/android/modules/SimpleServiceDiscovery.jsm
--- a/mobile/android/modules/SimpleServiceDiscovery.jsm
+++ b/mobile/android/modules/SimpleServiceDiscovery.jsm
@@ -64,48 +64,42 @@ var SimpleServiceDiscovery = {
     return aURL;
   },
 
   // nsIUDPSocketListener implementation
   onPacketReceived: function(aSocket, aMessage) {
     // Listen for responses from specific targets. There could be more than one
     // available.
     let response = aMessage.data.split("\n");
-    let location;
-    let target;
-    let valid = false;
-    response.some(function(row) {
-      let header = row.toUpperCase();
-      if (header.startsWith("LOCATION")) {
-        location = row.substr(10).trim();
-      } else if (header.startsWith("ST")) {
-        target = row.substr(4).trim();
-        if (this._targets.has(target)) {
-          valid = true;
-        }
+    let service = {};
+    response.forEach(function(row) {
+      let name = row.toUpperCase();
+      if (name.startsWith("LOCATION")) {
+        service.location = row.substr(10).trim();
+      } else if (name.startsWith("ST")) {
+        service.target = row.substr(4).trim();
+      } else if (name.startsWith("SERVER")) {
+        service.server = row.substr(8).trim();
+      }
+    }.bind(this));
+
+    if (service.location && this._targets.has(service.target)) {
+      service.location = this._forceTrailingSlash(service.location);
+
+      // We add the server as an additional way to filter services
+      if (!("server" in service)) {
+        service.server = null;
       }
 
-      if (location && valid) {
-        location = this._forceTrailingSlash(location);
-
-        // When we find a valid response, package up the service information
-        // and pass it on.
-        let service = {
-          location: location,
-          target: target
-        };
-
-        try {
-          this._processService(service);
-        } catch (e) {}
-
-        return true;
-      }
-      return false;
-    }.bind(this));
+      // When we find a valid response, package up the service information
+      // and pass it on.
+      try {
+        this._processService(service);
+      } catch (e) {}
+    }
   },
 
   onStopListening: function(aSocket, aStatus) {
     // This is fired when the socket is closed expectedly or unexpectedly.
     // nsITimer.cancel() is a no-op if the timer is not active.
     this._searchTimeout.cancel();
     this._searchSocket = null;
   },