addressdb revision dafcb997e390efa4423883dafd100c975c4095d6
fc80027fb54b501cdd88461bf879d078259e0226David LawrenceCopyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
ca41b452ede6feaa9d8739ec3cae19389a7b0d03Bob HalleyCopyright (C) 2000, 2001 Internet Software Consortium.
fc80027fb54b501cdd88461bf879d078259e0226David LawrenceSee COPYRIGHT in the source root or http://isc.org/copyright.html for terms.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence$Id: addressdb,v 1.6 2004/03/05 05:04:45 marka Exp $
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David LawrenceYou are lost in a maze of twisty little pointers, all alike...
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David LawrenceADB |-> 0 |-> handle ---> handle ---> 0
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence | | |
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence |-lists of names --------> name -------> name -------> 0
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence | | |
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence | namehook namehook
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence | | | | |
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence | | 0 0 -> fetch
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence | |
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence | V
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrence |-lists of elements -----> element ----> element ----> element ---> 0
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence | | | |
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence | |-> zoneinfo |-> 0 |-> zoneinfo
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence |-lists of dead handles
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence ...
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
899f7f9af527d3dfe8345dcc8210d7c23fc950afDavid LawrenceA handle contains a task, taskaction, and event argument, and is linkable
c4717613e45323ed23dc6e9162cba89f1f83830cDavid Lawrencein two ways. One, for the list returned to the caller, and two to be
fc80027fb54b501cdd88461bf879d078259e0226David Lawrenceattached to either a name (so events can be generated) or to the dead handle
fc80027fb54b501cdd88461bf879d078259e0226David Lawrencelist, where no events are generated.
8f804834e2b537da5c8bc81f986143a46147b490Andreas Gustafsson
fc80027fb54b501cdd88461bf879d078259e0226David LawrenceHANDLE
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence |
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence |--- addrinfo ---> addrinfo ---> 0
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence | |-> entry |-> entry
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence |--- task, action, arg
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence |
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence V
fc80027fb54b501cdd88461bf879d078259e0226David LawrenceHANDLE
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence |
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence V
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence 0
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David LawrenceNotes and questions:
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence o If a handle is on the dead handle list, it is only waiting for
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence the caller to dns_adb_done() it.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence o If a handle is on a name list, it will generate at most one
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence event, and then be moved to the dead handle list.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence o If events are not requested, it is NEVER placed on the name's
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence list, even though fetches for that name may be started.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence o Names will have to have a reference count for each fetch
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence in progress. They will also have a bit that says some
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence previous fetches failed. XXX How in the world would I
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence "refresh" the data? If I only got 2 of 9 A6 chains to converge,
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence when and how do I restart them later?
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence o The caller will give us a name, and we will return two items:
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence a handle and a list of addresses. If the list was non-empty when
2918b5bda6a55c301eb87992b5f2acd7176d0737David Lawrence it was given to us, we will append (unique) addrinfo's to the list.
2918b5bda6a55c301eb87992b5f2acd7176d0737David Lawrence
2918b5bda6a55c301eb87992b5f2acd7176d0737David Lawrence o How in the world do you shut this thing down?
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence If you cancel the fetches first:
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence 1. The handles are sent an event saying "no more
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence names are coming."
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence 2. The handles are moved to the dead handle list.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence If you cancel the handles first:
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence 1. The handles are moved to the dead handle list.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence It would therefore seem simpler to cancel/done all handles first,
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence then all fetches.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence o If a fetch returns a CNAME, what do we do?
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
d409ceeda41a256e8114423674d844d5f5035ee8Bob Halley o If a fetch returns a DNAME, what do we do?
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
8f804834e2b537da5c8bc81f986143a46147b490Andreas Gustafsson o If a fetch returns 4 ipv4 addresses, we will have to allocate
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence 3 more (total of 4) namehooks, 4 entries, and fill them in.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence What happens if only some of these can be allocated?
8f804834e2b537da5c8bc81f986143a46147b490Andreas Gustafsson
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence o ipv6 raises the memory problem to a new level. What if we
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence have to fork into multiple chains, but we run out of memory?
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
8f804834e2b537da5c8bc81f986143a46147b490Andreas Gustafsson----------------------------------------------------------------------
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David LawrenceLooking up entries via names:
8f804834e2b537da5c8bc81f986143a46147b490Andreas Gustafsson
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence Look for the name in the database.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence FOUND:
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence For each complete address, allocate an addrinfo structure
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence and add it to the handle.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence If any fetches are in progress for this name, attach this
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence handle to this name so events can be posted to the handle,
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence if the handle wants events.
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrence
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrence If no fetches are in progress and the name is incomplete,
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence see if we can start a fetch for this name.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence NOT FOUND:
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence Create a new adbname structure.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence Create a new namehook structure.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence Start a fetch on this name.
61e9c1cdbe29683bb2db388e4fc6a6fd59315cefDavid Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence If more data is coming (fetches are in progress) attach
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence the handle to the name, so it can get notification of
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence new data.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence If the name is incomplete (due to fetches in progress,
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence recently failed fetches, or the inability to start new
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence fetches) copy the incomplete flag to the handle, so the
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence caller can know this.
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence