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

RESOLVED WORKSFORME

Status

()

P2
normal
RESOLVED WORKSFORME
16 years ago
15 years ago

People

(Reporter: benc, Assigned: gordon)

Tracking

({regression})

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

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Reporter)

Description

16 years ago
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.

Comment 1

16 years ago
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
Last Resolved: 16 years ago
Resolution: --- → WORKSFORME
(Reporter)

Comment 2

16 years ago
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
(Assignee)

Comment 3

16 years ago
This is currently broken.
Status: VERIFIED → REOPENED
Resolution: WORKSFORME → ---
(Assignee)

Comment 4

16 years ago
I'll take it.
Assignee: dougt → gordon
Status: REOPENED → NEW
(Reporter)

Comment 5

16 years ago
*** Bug 196362 has been marked as a duplicate of this bug. ***

Updated

16 years ago
Flags: blocking1.4a?
Keywords: nsbeta1, regression

Updated

16 years ago
Flags: blocking1.4a? → blocking1.4a-

Comment 6

16 years ago
*** Bug 200772 has been marked as a duplicate of this bug. ***

Comment 7

16 years ago
.
Assignee: gordon → timeless
Summary: DNS: Offline->Online clears DNS cache → DNS: Offline->Online does not clear the DNS cache
(Assignee)

Comment 9

16 years ago
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

Comment 10

16 years ago
Created attachment 119942 [details] [diff] [review]
clear cache
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
(Assignee)

Comment 12

16 years ago
Created attachment 120267 [details] [diff] [review]
patch to clear dns cache after toggling offline/online

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
(Assignee)

Comment 13

16 years ago
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)
(Assignee)

Comment 14

16 years ago
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)
(Assignee)

Updated

16 years ago
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → mozilla1.4beta

Comment 15

16 years ago
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+

Comment 17

16 years ago
*** Bug 202565 has been marked as a duplicate of this bug. ***
(Assignee)

Comment 18

16 years ago
Patch checked in.  Marking FIXED.
Status: ASSIGNED → RESOLVED
Last Resolved: 16 years ago16 years ago
Resolution: --- → FIXED

Comment 19

16 years ago
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.
(Reporter)

Comment 20

16 years ago
Felix: I've created bug 209729, based on your comment.
(Reporter)

Comment 21

16 years ago
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 → ---

Comment 22

16 years ago
adt: nsbeta1-
Keywords: nsbeta1 → nsbeta1-

Comment 23

16 years ago
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.

Comment 24

16 years ago
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?
(Reporter)

Comment 25

15 years ago
Scott,

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

Comment 26

15 years ago
WORKSFORME
Status: REOPENED → RESOLVED
Last Resolved: 16 years ago15 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.