| @@ -677,38 +677,36 @@ mDNSlocal void SetNextAnnounceProbeTime( | | | @@ -677,38 +677,36 @@ mDNSlocal void SetNextAnnounceProbeTime( |
677 | if (rr->resrec.RecordType == kDNSRecordTypeUnique) | | 677 | if (rr->resrec.RecordType == kDNSRecordTypeUnique) |
678 | { | | 678 | { |
679 | if ((rr->LastAPTime + rr->ThisAPInterval) - m->timenow > mDNSPlatformOneSecond * 10) | | 679 | if ((rr->LastAPTime + rr->ThisAPInterval) - m->timenow > mDNSPlatformOneSecond * 10) |
680 | { | | 680 | { |
681 | LogMsg("SetNextAnnounceProbeTime: ProbeCount %d Next in %d %s", rr->ProbeCount, (rr->LastAPTime + rr->ThisAPInterval) - m->timenow, ARDisplayString(m, rr)); | | 681 | LogMsg("SetNextAnnounceProbeTime: ProbeCount %d Next in %d %s", rr->ProbeCount, (rr->LastAPTime + rr->ThisAPInterval) - m->timenow, ARDisplayString(m, rr)); |
682 | LogMsg("SetNextAnnounceProbeTime: m->SuppressProbes %d m->timenow %d diff %d", m->SuppressProbes, m->timenow, m->SuppressProbes - m->timenow); | | 682 | LogMsg("SetNextAnnounceProbeTime: m->SuppressProbes %d m->timenow %d diff %d", m->SuppressProbes, m->timenow, m->SuppressProbes - m->timenow); |
683 | } | | 683 | } |
684 | if (m->NextScheduledProbe - (rr->LastAPTime + rr->ThisAPInterval) >= 0) | | 684 | if (m->NextScheduledProbe - (rr->LastAPTime + rr->ThisAPInterval) >= 0) |
685 | m->NextScheduledProbe = (rr->LastAPTime + rr->ThisAPInterval); | | 685 | m->NextScheduledProbe = (rr->LastAPTime + rr->ThisAPInterval); |
686 | // Some defensive code: | | 686 | // Some defensive code: |
687 | // If (rr->LastAPTime + rr->ThisAPInterval) happens to be far in the past, we don't want to allow | | 687 | // If (rr->LastAPTime + rr->ThisAPInterval) happens to be far in the past, we don't want to allow |
688 | // NextScheduledProbe to be set excessively in the past, because that can cause bad things to happen. | | 688 | // NextScheduledProbe to be set excessively in the past, because that can cause bad things to happen. |
689 | // See: <rdar://problem/7795434> mDNS: Sometimes advertising stops working and record interval is set to zero | | 689 | // See: <rdar://problem/7795434> mDNS: Sometimes advertising stops working and record interval is set to zero |
690 | // A future time also needs to be set to avoid spamming logs about not all probes being sent. | | 690 | if (m->NextScheduledProbe - m->timenow < 0) |
691 | if (m->NextScheduledProbe - m->timenow <= 0) | | 691 | m->NextScheduledProbe = m->timenow; |
692 | m->NextScheduledProbe = m->timenow + 1; | | | |
693 | } | | 692 | } |
694 | else if (rr->AnnounceCount && (ResourceRecordIsValidAnswer(rr) || rr->resrec.RecordType == kDNSRecordTypeDeregistering)) | | 693 | else if (rr->AnnounceCount && (ResourceRecordIsValidAnswer(rr) || rr->resrec.RecordType == kDNSRecordTypeDeregistering)) |
695 | { | | 694 | { |
696 | if (m->NextScheduledResponse - (rr->LastAPTime + rr->ThisAPInterval) >= 0) | | 695 | if (m->NextScheduledResponse - (rr->LastAPTime + rr->ThisAPInterval) >= 0) |
697 | m->NextScheduledResponse = (rr->LastAPTime + rr->ThisAPInterval); | | 696 | m->NextScheduledResponse = (rr->LastAPTime + rr->ThisAPInterval); |
698 | } | | 697 | } |
699 | // A future time also needs to be set to avoid spamming logs about not all responses being sent. | | 698 | if (m->NextScheduledResponse - m->timenow < 0) |
700 | if (m->NextScheduledResponse - m->timenow <= 0) | | 699 | m->NextScheduledResponse = m->timenow; |
701 | m->NextScheduledResponse = m->timenow + 1; | | | |
702 | } | | 700 | } |
703 | | | 701 | |
704 | mDNSlocal void InitializeLastAPTime(mDNS *const m, AuthRecord *const rr) | | 702 | mDNSlocal void InitializeLastAPTime(mDNS *const m, AuthRecord *const rr) |
705 | { | | 703 | { |
706 | // For reverse-mapping Sleep Proxy PTR records, probe interval is one second | | 704 | // For reverse-mapping Sleep Proxy PTR records, probe interval is one second |
707 | rr->ThisAPInterval = rr->AddressProxy.type ? mDNSPlatformOneSecond : DefaultAPIntervalForRecordType(rr->resrec.RecordType); | | 705 | rr->ThisAPInterval = rr->AddressProxy.type ? mDNSPlatformOneSecond : DefaultAPIntervalForRecordType(rr->resrec.RecordType); |
708 | | | 706 | |
709 | // * If this is a record type that's going to probe, then we use the m->SuppressProbes time. | | 707 | // * If this is a record type that's going to probe, then we use the m->SuppressProbes time. |
710 | // * Otherwise, if it's not going to probe, but m->SuppressProbes is set because we have other | | 708 | // * Otherwise, if it's not going to probe, but m->SuppressProbes is set because we have other |
711 | // records that are going to probe, then we delay its first announcement so that it will | | 709 | // records that are going to probe, then we delay its first announcement so that it will |
712 | // go out synchronized with the first announcement for the other records that *are* probing. | | 710 | // go out synchronized with the first announcement for the other records that *are* probing. |
713 | // This is a minor performance tweak that helps keep groups of related records synchronized together. | | 711 | // This is a minor performance tweak that helps keep groups of related records synchronized together. |
714 | // The addition of "interval / 2" is to make sure that, in the event that any of the probes are | | 712 | // The addition of "interval / 2" is to make sure that, in the event that any of the probes are |
| @@ -4489,36 +4487,36 @@ mDNSexport mDNSs32 mDNS_Execute(mDNS *co | | | @@ -4489,36 +4487,36 @@ mDNSexport mDNSs32 mDNS_Execute(mDNS *co |
4489 | if (m->timenow - m->NextScheduledQuery >= 0 || m->timenow - m->NextScheduledProbe >= 0) SendQueries(m); | | 4487 | if (m->timenow - m->NextScheduledQuery >= 0 || m->timenow - m->NextScheduledProbe >= 0) SendQueries(m); |
4490 | if (m->timenow - m->NextScheduledQuery >= 0) | | 4488 | if (m->timenow - m->NextScheduledQuery >= 0) |
4491 | { | | 4489 | { |
4492 | DNSQuestion *q; | | 4490 | DNSQuestion *q; |
4493 | LogMsg("mDNS_Execute: SendQueries didn't send all its queries (%d - %d = %d) will try again in one second", | | 4491 | LogMsg("mDNS_Execute: SendQueries didn't send all its queries (%d - %d = %d) will try again in one second", |
4494 | m->timenow, m->NextScheduledQuery, m->timenow - m->NextScheduledQuery); | | 4492 | m->timenow, m->NextScheduledQuery, m->timenow - m->NextScheduledQuery); |
4495 | m->NextScheduledQuery = m->timenow + mDNSPlatformOneSecond; | | 4493 | m->NextScheduledQuery = m->timenow + mDNSPlatformOneSecond; |
4496 | for (q = m->Questions; q && q != m->NewQuestions; q=q->next) | | 4494 | for (q = m->Questions; q && q != m->NewQuestions; q=q->next) |
4497 | if (ActiveQuestion(q) && m->timenow - NextQSendTime(q) >= 0) | | 4495 | if (ActiveQuestion(q) && m->timenow - NextQSendTime(q) >= 0) |
4498 | LogMsg("mDNS_Execute: SendQueries didn't send %##s (%s)", q->qname.c, DNSTypeName(q->qtype)); | | 4496 | LogMsg("mDNS_Execute: SendQueries didn't send %##s (%s)", q->qname.c, DNSTypeName(q->qtype)); |
4499 | } | | 4497 | } |
4500 | if (m->timenow - m->NextScheduledProbe >= 0) | | 4498 | if (m->timenow - m->NextScheduledProbe >= 0) |
4501 | { | | 4499 | { |
4502 | LogMsg("mDNS_Execute: SendQueries didn't send all its probes (%d - %d = %d) will try again in one second", | | 4500 | debugf("mDNS_Execute: SendQueries didn't send all its probes (%d - %d = %d) will try again in one second", |
4503 | m->timenow, m->NextScheduledProbe, m->timenow - m->NextScheduledProbe); | | 4501 | m->timenow, m->NextScheduledProbe, m->timenow - m->NextScheduledProbe); |
4504 | m->NextScheduledProbe = m->timenow + mDNSPlatformOneSecond; | | 4502 | m->NextScheduledProbe = m->timenow + mDNSPlatformOneSecond; |
4505 | } | | 4503 | } |
4506 | | | 4504 | |
4507 | // 8. Send Response packets, including probing records just advanced to announcing state | | 4505 | // 8. Send Response packets, including probing records just advanced to announcing state |
4508 | if (m->timenow - m->NextScheduledResponse >= 0) SendResponses(m); | | 4506 | if (m->timenow - m->NextScheduledResponse >= 0) SendResponses(m); |
4509 | if (m->timenow - m->NextScheduledResponse >= 0) | | 4507 | if (m->timenow - m->NextScheduledResponse >= 0) |
4510 | { | | 4508 | { |
4511 | LogMsg("mDNS_Execute: SendResponses didn't send all its responses; will try again in one second"); | | 4509 | debugf("mDNS_Execute: SendResponses didn't send all its responses; will try again in one second"); |
4512 | m->NextScheduledResponse = m->timenow + mDNSPlatformOneSecond; | | 4510 | m->NextScheduledResponse = m->timenow + mDNSPlatformOneSecond; |
4513 | } | | 4511 | } |
4514 | } | | 4512 | } |
4515 | | | 4513 | |
4516 | // Clear RandomDelay values, ready to pick a new different value next time | | 4514 | // Clear RandomDelay values, ready to pick a new different value next time |
4517 | m->RandomQueryDelay = 0; | | 4515 | m->RandomQueryDelay = 0; |
4518 | m->RandomReconfirmDelay = 0; | | 4516 | m->RandomReconfirmDelay = 0; |
4519 | | | 4517 | |
4520 | if (m->NextScheduledStopTime && m->timenow - m->NextScheduledStopTime >= 0) TimeoutQuestions(m); | | 4518 | if (m->NextScheduledStopTime && m->timenow - m->NextScheduledStopTime >= 0) TimeoutQuestions(m); |
4521 | #ifndef UNICAST_DISABLED | | 4519 | #ifndef UNICAST_DISABLED |
4522 | if (m->NextSRVUpdate && m->timenow - m->NextSRVUpdate >= 0) UpdateAllSRVRecords(m); | | 4520 | if (m->NextSRVUpdate && m->timenow - m->NextSRVUpdate >= 0) UpdateAllSRVRecords(m); |
4523 | if (m->timenow - m->NextScheduledNATOp >= 0) CheckNATMappings(m); | | 4521 | if (m->timenow - m->NextScheduledNATOp >= 0) CheckNATMappings(m); |
4524 | if (m->timenow - m->NextuDNSEvent >= 0) uDNS_Tasks(m); | | 4522 | if (m->timenow - m->NextuDNSEvent >= 0) uDNS_Tasks(m); |