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