DNS: Offline->Online does not clear the DNS cache

RESOLVED WORKSFORME

Status

()

defect
P2
normal
RESOLVED WORKSFORME
17 years ago
16 years ago

People

(Reporter: benc, Assigned: gordon)

Tracking

({regression})

Trunk
mozilla1.4beta
Points:
---
Bug Flags:
blocking1.4a -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

CONFIRMED: Mozilla 1.3a, Mac OS X

This behavior was added at some point, but I could not find a bug, so I'm
creating it now.

STEPS:
Using some DNS server logging (I used snoop), if you go to the same hostname
several times, you only see a DNS request for the first time.

If you click offline, then online, and go to the same hostname again, you find
that DNS is requested again, just once, for the hostname.

If anyone could put some comments about where and when this change was made,
that would be helpful.
benc:

this has been a feature of necko for as long as i have been working on it.  it
may have been broken at one point when the DNS service wasn't being shutdown as
a result of going offline.

no reason to keep this bug open.  marking WORKSFORME.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → WORKSFORME
VERIFIED:
just needed to document this somewhere, because I don't think I ever stumbled
across the bug that explained this was a feature.
Status: RESOLVED → VERIFIED
OS: MacOS X → All
Hardware: Macintosh → All
This is currently broken.
Status: VERIFIED → REOPENED
Resolution: WORKSFORME → ---
I'll take it.
Assignee: dougt → gordon
Status: REOPENED → NEW
*** Bug 196362 has been marked as a duplicate of this bug. ***
Flags: blocking1.4a?
Keywords: nsbeta1, regression
Flags: blocking1.4a? → blocking1.4a-
*** Bug 200772 has been marked as a duplicate of this bug. ***
.
Assignee: gordon → timeless
Summary: DNS: Offline->Online clears DNS cache → DNS: Offline->Online does not clear the DNS cache
Posted patch draft (obsolete) — Splinter Review
Timeless, this patch doesn't clear the DNS cache, and it would cause a
regression by potentially locking up the UI when we go offline.  This bug is
actually a regression from that one.

This would be fixed by the move to multiple lookup threads we've been
contemplating, but I think I know a simpler way to fix this in the meantime. 
I'll try to post a patch later today or tomorrow.
Assignee: timeless → gordon
Posted patch clear cache (obsolete) — Splinter Review
Attachment #119691 - Attachment is obsolete: true
Comment on attachment 119942 [details] [diff] [review]
clear cache

>-    if (!nsCRT::strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, topic))
>+    if (!strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, topic))
>     {

Someone previously didn't follow prevailing brace style, here -- fix?

>         // we need to shutdown!
>         ShutdownInternal(); 
>         return NS_OK;
>     }
> 
>-    if (nsCRT::strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, topic))  
>+    NS_ConvertUCS2toUTF8 observerData(data);
>+    if (!strcmp("network:offline-status-changed", topic) &&
>+        !strcmp("online", observerData.get())) {
>+        // Force a reset

Don't construct observerData until you know you need it (after the first clause
of the && is known to be true) -- split that if condition across two ifs, with
the observerData declaration in the outer then block.

/be
The DNS service already gets called when going offline, so we don't need any
observer code.	We simply set a flag in the Shutdown() to clear the dns cache
and reset the resolver the next time we get called to Lookup() or Resolve() a
hostname.
Attachment #119942 - Attachment is obsolete: true
Comment on attachment 120267 [details] [diff] [review]
patch to clear dns cache after toggling offline/online

Darin, your thoughts and comments will be appreciated.	Any recommendations for
a reviewer?  Thanks.
Attachment #120267 - Flags: superreview?(darin)
Comment on attachment 120267 [details] [diff] [review]
patch to clear dns cache after toggling offline/online

Doug, can you review this as well?  Thanks.
Attachment #120267 - Flags: review?(dougt)
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → mozilla1.4beta
Comment on attachment 120267 [details] [diff] [review]
patch to clear dns cache after toggling offline/online

>+        if (mCacheNeedsClearing) {
>+            EvictLookupsIfNecessary(0);     // clear cache
>+            Reset();                        // reset resolver
>+            mCacheNeedsClearing = PR_FALSE;
>+        }
>+
>         PLDHashEntryHdr * hashEntry = PL_DHashTableOperate(&mHashTable, i_hostname, PL_DHASH_LOOKUP);

no need to lookup in hash table if you just cleared the cache.	an
else clause is probably all that's needed.

sr=darin with that change.
Attachment #120267 - Flags: superreview?(darin) → superreview+
Comment on attachment 120267 [details] [diff] [review]
patch to clear dns cache after toggling offline/online

what darin said.
Attachment #120267 - Flags: review?(dougt) → review+
*** Bug 202565 has been marked as a duplicate of this bug. ***
Patch checked in.  Marking FIXED.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago17 years ago
Resolution: --- → FIXED
I guess now, if there isn't one already, we need a way to reload DNS/hosts
without going offline, which disconnects Chatzilla (remote closed the
connection) at offline without reconnecting at online.
Felix: I've created bug 209729, based on your comment.
REOPEN:
Mach-O, Mozilla 1.4b
WinXP, Mozilla 1.4 daily (20030612)

Maybe there is some OS-level caching that interfers w/ my test. 

I'm basically running a packet trace on the UDP port of the DNS server, and then
initiating browser activity that is not cached to the same hostname.

The cache is working: a single request for each host visited. However, after
clicking on the toggle button, only Linux begins to send out a new set of
queries for previously cached hostnames.

I've also noticed that for Linux, it does work, but not completely consistently
(90%) of the time. I also suspect that you have to double-click the toggle (go
offline and then go right back online).
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
adt: nsbeta1-
Keywords: nsbeta1nsbeta1-
WinXP:WorksForMe, Mozilla 1.5b.
benc: please reconfirm within a week, or I'll close it; otherwise I can reassign
it to the component owner.  I was able to flush an expired entry by selecting
"File..Work Offline" twice, for a website whose IP had changed.
Any idea as to how this will be handled in Firebird, as there is no
"online/Offline" button in the status bar and no "File > Work Offline" in the menu?
Scott,

You should create a firebird bug that depends on this. I don't know what they
plan to do in this regard.

WORKSFORME
Status: REOPENED → RESOLVED
Closed: 17 years ago16 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.