MCPcopy Create free account
hub / github.com/apache/trafficserver / dnsEvent

Method dnsEvent

src/iocore/hostdb/HostDB.cc:917–1139  ·  view source on GitHub ↗

DNS lookup result state

Source from the content-addressed store, hash-verified

915
916// DNS lookup result state
917int
918HostDBContinuation::dnsEvent(int event, HostEnt *e)
919{
920 if (timeout) {
921 timeout->cancel(this);
922 timeout = nullptr;
923 }
924 EThread *thread = mutex->thread_holding;
925 if (event != DNS_EVENT_LOOKUP) {
926 // Event should be immediate or interval.
927 if (!action.continuation) {
928 // Nothing to do, give up.
929 if (event == EVENT_INTERVAL) {
930 // Timeout - clear all queries queued up for this FQDN because none of the other ones have sent an
931 // actual DNS query. If the request rate is high enough this can cause a persistent queue where the
932 // DNS query is never sent and all requests timeout, even if it was a transient error.
933 // See issue #8417.
934 remove_and_trigger_pending_dns();
935 } else {
936 // "local" signal to give up, usually due this being one of those "other" queries.
937 // That generally means @a this has already been removed from the queue, but just in case...
938 hostDB.pending_dns_for_hash(hash.hash).remove(this);
939 }
940 if (hostDB.remove_from_pending_dns_for_hash(hash.hash, this)) {
941 hostdb_cont_free(this);
942 }
943 return EVENT_DONE;
944 }
945 MUTEX_TRY_LOCK(lock, action.mutex, thread);
946 if (!lock.is_locked()) {
947 timeout = thread->schedule_in(this, HOST_DB_RETRY_PERIOD);
948 return EVENT_CONT;
949 }
950 // [amc] Callback to client to indicate a failure due to timeout.
951 // We don't try a different family here because a timeout indicates
952 // a server issue that won't be fixed by asking for a different
953 // address family.
954 if (!action.cancelled && action.continuation) {
955 action.continuation->handleEvent(EVENT_HOST_DB_LOOKUP, nullptr);
956 }
957 action = nullptr;
958 return EVENT_DONE;
959 } else {
960 bool failed = !e || !e->good;
961
962 pending_action = nullptr;
963
964 ttl = ts_seconds(failed ? 0 : e->ttl);
965
966 Ptr<HostDBRecord> old_r = probe(hash, false);
967 // If the DNS lookup failed with NXDOMAIN, remove the old record
968 if (e && e->isNameError() && old_r) {
969 hostDB.refcountcache->erase(old_r->key);
970 old_r = nullptr;
971 Dbg(dbg_ctl_hostdb, "Removing the old record when the DNS lookup failed with NXDOMAIN");
972 }
973
974 int valid_records = 0;

Callers

nothing calls this directly

Calls 15

refresh_hashMethod · 0.95
hostdb_cont_freeFunction · 0.85
probeFunction · 0.85
is_addr_validFunction · 0.85
strcmpFunction · 0.85
check_for_retryFunction · 0.85
reply_to_contFunction · 0.85
isNameErrorMethod · 0.80
is_bynameMethod · 0.80
rr_infoMethod · 0.80

Tested by

no test coverage detected