<rdar://problem/7302554> mDNSResponder keeps sending WAB queries when DNS configurati...
authormparthasarathy@apple.com <mparthasarathy@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Mon, 19 Oct 2009 20:16:47 +0000 (20:16 +0000)
committermparthasarathy@apple.com <mparthasarathy@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Mon, 19 Oct 2009 20:16:47 +0000 (20:16 +0000)
git-svn-id: http://svn.macosforge.org/repository/mDNSResponder/trunk@6746 214c2c4a-bf3b-4dcf-9390-e4dd3010487d

mDNSCore/mDNS.c

index 9e418dc..6a34293 100755 (executable)
@@ -5147,8 +5147,36 @@ mDNSlocal void mDNSCoreReceiveResponse(mDNS *const m,
                                                }
                                        else if (m->rec.r.resrec.rroriginalttl > 0)
                                                {
+                                               DNSQuestion *q;
                                                //if (rr->resrec.rroriginalttl == 0) LogMsg("uDNS rescuing %s", CRDisplayString(m, rr));
                                                RefreshCacheRecord(m, rr, m->rec.r.resrec.rroriginalttl);
+
+                                               // We have to reset the question interval to MaxQuestionInterval so that we don't keep
+                                               // polling the network once we get a valid response back. For the first time when a new
+                                               // cache entry is created, AnswerCurrentQuestionWithResourceRecord does that.
+                                               // Subsequently, if we reissue questions from within the mDNSResponder e.g., DNS server
+                                               // configuration changed, without flushing the cache, we reset the question interval here.
+                                               // Currently, we do this for for both multicast and unicast questions as long as the record
+                                               // type is unique. For unicast, resource record is always unique and for multicast it is
+                                               // true for records like A etc. but not for PTR.
+                                               if (rr->resrec.RecordType & kDNSRecordTypePacketUniqueMask)
+                                                       {
+                                                       for (q = m->Questions; q; q=q->next)
+                                                               {
+
+                                                               if (!q->DuplicateOf && !q->LongLived && 
+                                                                       ActiveQuestion(q) && ResourceRecordAnswersQuestion(&rr->resrec, q))
+                                                                       {
+                                                                       q->LastQTime        = m->timenow;
+                                                                       q->LastQTxTime      = m->timenow;
+                                                                       q->RecentAnswerPkts = 0;
+                                                                       q->ThisQInterval    = MaxQuestionInterval;
+                                                                       q->RequestUnicast   = mDNSfalse;
+                                                                       debugf("mDNSCoreReceiveResponse: Set MaxQuestionInterval for %##s (%s)", q->qname.c, DNSTypeName(q->qtype));
+                                                                       break;
+                                                                       }
+                                                               }
+                                                       }
                                                break;
                                                }
                                        else