Bug 1321841 - Better checksum for "live" adapters. r=bagder
authorLiang-Heng Chen <xeonchen@gmail.com>
Wed, 18 Jan 2017 05:40:00 -0500
changeset 377430 111109712e7700e8544d0da27589016662d48399
parent 377429 fe7445d0ec0a017bb016fad6a21ae8f1d5bf0984
child 377431 bbbbcc7e8a1bf0b432f22a04994d920a091c591f
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbagder
bugs1321841
milestone53.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 1321841 - Better checksum for "live" adapters. r=bagder MozReview-Commit-ID: Ldql5weiLyy
netwerk/system/win32/nsNotifyAddrListener.cpp
--- a/netwerk/system/win32/nsNotifyAddrListener.cpp
+++ b/netwerk/system/win32/nsNotifyAddrListener.cpp
@@ -630,55 +630,57 @@ nsNotifyAddrListener::CheckAdaptersAddre
     }
 
     //
     // Since NotifyIpInterfaceChange() signals a change more often than we
     // think is a worthy change, we checksum the entire state of all interfaces
     // that are UP. If the checksum is the same as previous check, nothing
     // of interest changed!
     //
-    ULONG sum = 0;
+    ULONG sumAll = 0;
 
     if (ret == ERROR_SUCCESS) {
         bool linkUp = false;
+        ULONG sum = 0;
 
         for (PIP_ADAPTER_ADDRESSES adapter = adapterList; adapter;
              adapter = adapter->Next) {
             if (adapter->OperStatus != IfOperStatusUp ||
                 !adapter->FirstUnicastAddress ||
                 adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK ||
                 CheckICSGateway(adapter) ) {
                 continue;
             }
 
+            sum <<= 2;
             // Add chars from AdapterName to the checksum.
             for (int i = 0; adapter->AdapterName[i]; ++i) {
-                sum <<= 2;
                 sum += adapter->AdapterName[i];
             }
 
             // Add bytes from each socket address to the checksum.
             for (PIP_ADAPTER_UNICAST_ADDRESS pip = adapter->FirstUnicastAddress;
                  pip; pip = pip->Next) {
                 SOCKET_ADDRESS *sockAddr = &pip->Address;
                 for (int i = 0; i < sockAddr->iSockaddrLength; ++i) {
                     sum += (reinterpret_cast<unsigned char *>
                             (sockAddr->lpSockaddr))[i];
                 }
             }
             linkUp = true;
+            sumAll ^= sum;
         }
         mLinkUp = linkUp;
         mStatusKnown = true;
     }
     free(adapterList);
 
     if (mLinkUp) {
         /* Store the checksum only if one or more interfaces are up */
-        mIPInterfaceChecksum = sum;
+        mIPInterfaceChecksum = sumAll;
     }
 
     CoUninitialize();
 
     return ret;
 }
 
 /**