Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  test_dns_drain_loop.js   Sprache: JAVA

 

"use strict";

// Verify that the resolver's drain loop picks up all queued records even
// when only one pool thread is available. This is the key behavior changed
// by bug 1478732: instead of each thread blocking in GetHostToLookup(),
// ResolveHostTask loops to DequeueNextRecord() after each completion.

class DNSListener {
  constructor() {
    this.promise = new Promise(resolve => {
      this._resolve = resolve;
    });
  }

  onLookupComplete(request, record, status) {
    this._resolve({ request, record, status });
  }
}
DNSListener.prototype.QueryInterface = ChromeUtils.generateQI([
  "nsIDNSListener",
]);

add_task(async function drain_loop_single_thread() {
  // Limit to a single any-priority slot. All lookups below are default
  // (medium) priority, so only one can be in flight at a time.
  Services.prefs.setIntPref("network.dns.max_any_priority_threads", 1);
  Services.prefs.setIntPref("network.dns.max_high_priority_threads", 1);

  registerCleanupFunction(() => {
    Services.prefs.clearUserPref("network.dns.max_any_priority_threads");
    Services.prefs.clearUserPref("network.dns.max_high_priority_threads");
  });

  Services.dns.clearCache(true);

  const COUNT = 10;
  const flags =
    Ci.nsIDNSService.RESOLVE_BYPASS_CACHE |
    Ci.nsIDNSService.RESOLVE_DEFAULT_FLAGS;

  // Fire all lookups before any can complete.
  const listeners = [];
  for (let i = 0; i < COUNT; i++) {
    const listener = new DNSListener();
    listeners.push(listener);
    Services.dns.asyncResolve(
      `drain-loop-${i}.test`,
      Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
      flags,
      null,
      listener,
      Services.tm.mainThread,
      {}
    );
  }

  // All must complete even with a single thread.
  const results = await Promise.all(listeners.map(l => l.promise));
  Assert.strictEqual(results.length, COUNT, `All ${COUNT} lookups completed`);

  for (let i = 0; i < COUNT; i++) {
    // .test domains will fail resolution, but the callback must still fire.
    Assert.notStrictEqual(
      results[i].status,
      undefined,
      `Lookup ${i} got a status`
    );
  }
});

// Verify that lookups blocked by the mActiveAnyThreadCount priority limit
// still complete once earlier lookups finish and free up slots.
add_task(async function drain_loop_priority_limit() {
  // Allow only 1 any-priority thread but several high-priority threads.
  // This means only 1 med/low lookup can be in flight at a time.
  Services.prefs.setIntPref("network.dns.max_any_priority_threads", 1);
  Services.prefs.setIntPref("network.dns.max_high_priority_threads", 4);

  registerCleanupFunction(() => {
    Services.prefs.clearUserPref("network.dns.max_any_priority_threads");
    Services.prefs.clearUserPref("network.dns.max_high_priority_threads");
  });

  Services.dns.clearCache(true);

  const COUNT = 10;
  // Default flags = medium priority, subject to the any-priority limit.
  const flags =
    Ci.nsIDNSService.RESOLVE_BYPASS_CACHE |
    Ci.nsIDNSService.RESOLVE_DEFAULT_FLAGS;

  const listeners = [];
  for (let i = 0; i < COUNT; i++) {
    const listener = new DNSListener();
    listeners.push(listener);
    Services.dns.asyncResolve(
      `drain-prio-${i}.test`,
      Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
      flags,
      null,
      listener,
      Services.tm.mainThread,
      {}
    );
  }

  // All must complete even though only 1 any-priority slot is available.
  const results = await Promise.all(listeners.map(l => l.promise));
  Assert.strictEqual(
    results.length,
    COUNT,
    `All ${COUNT} priority-limited lookups completed`
  );
});

Messung V0.5 in Prozent
C=87 H=80 G=83

¤ Dauer der Verarbeitung: 0.14 Sekunden  (vorverarbeitet am  2026-10-03) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1126438
#Domains=1867298