0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark AndrewsCopyright (C) 2000, 2001, 2004, 2016 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark AndrewsThis Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark AndrewsLicense, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrewsfile, You can obtain one at http://mozilla.org/MPL/2.0/.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews$Id: addressdb,v 1.6 2004/03/05 05:04:45 marka Exp $
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael GraffYou are lost in a maze of twisty little pointers, all alike...
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael GraffADB |-> 0 |-> handle ---> handle ---> 0
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff |-lists of names --------> name -------> name -------> 0
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff | namehook namehook
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff | | 0 0 -> fetch
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff |-lists of elements -----> element ----> element ----> element ---> 0
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff | |-> zoneinfo |-> 0 |-> zoneinfo
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff |-lists of dead handles
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael GraffA handle contains a task, taskaction, and event argument, and is linkable
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graffin two ways. One, for the list returned to the caller, and two to be
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graffattached to either a name (so events can be generated) or to the dead handle
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Grafflist, where no events are generated.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff |--- addrinfo ---> addrinfo ---> 0
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff | |-> entry |-> entry
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff |--- task, action, arg
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael GraffNotes and questions:
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff o If a handle is on the dead handle list, it is only waiting for
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff the caller to dns_adb_done() it.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff o If a handle is on a name list, it will generate at most one
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff event, and then be moved to the dead handle list.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff o If events are not requested, it is NEVER placed on the name's
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff list, even though fetches for that name may be started.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff o Names will have to have a reference count for each fetch
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff in progress. They will also have a bit that says some
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff previous fetches failed. XXX How in the world would I
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff "refresh" the data? If I only got 2 of 9 A6 chains to converge,
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff when and how do I restart them later?
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff o The caller will give us a name, and we will return two items:
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff a handle and a list of addresses. If the list was non-empty when
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff it was given to us, we will append (unique) addrinfo's to the list.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff o How in the world do you shut this thing down?
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff If you cancel the fetches first:
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff 1. The handles are sent an event saying "no more
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff names are coming."
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff 2. The handles are moved to the dead handle list.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff If you cancel the handles first:
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff 1. The handles are moved to the dead handle list.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff It would therefore seem simpler to cancel/done all handles first,
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff then all fetches.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff o If a fetch returns a CNAME, what do we do?
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff o If a fetch returns a DNAME, what do we do?
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff o If a fetch returns 4 ipv4 addresses, we will have to allocate
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff 3 more (total of 4) namehooks, 4 entries, and fill them in.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff What happens if only some of these can be allocated?
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff o ipv6 raises the memory problem to a new level. What if we
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff have to fork into multiple chains, but we run out of memory?
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff----------------------------------------------------------------------
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael GraffLooking up entries via names:
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff Look for the name in the database.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff For each complete address, allocate an addrinfo structure
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff and add it to the handle.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff If any fetches are in progress for this name, attach this
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff handle to this name so events can be posted to the handle,
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff if the handle wants events.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff If no fetches are in progress and the name is incomplete,
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff see if we can start a fetch for this name.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff Create a new adbname structure.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff Create a new namehook structure.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff Start a fetch on this name.
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff If more data is coming (fetches are in progress) attach
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff the handle to the name, so it can get notification of
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff If the name is incomplete (due to fetches in progress,
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff recently failed fetches, or the inability to start new
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff fetches) copy the incomplete flag to the handle, so the
79d29bd3206f9dfc77521bcdc516c5e255bc717dMichael Graff caller can know this.