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