diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2013-11-26 12:50:25 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2013-11-26 12:50:25 +0000 |
commit | 2992f3f66bb34468303d966934ac4a649d80cafd (patch) | |
tree | f7b3f2cd4652e6e11a942353f59a5e90c8114ddc /usr.sbin/nsd | |
parent | 7c4dd1e2c9edff83947ea6f52b5e8b534d2c8000 (diff) |
import NSD 4.0.0, tests from Dorian Büttner, Patrik Lundin, requested by brad@
Diffstat (limited to 'usr.sbin/nsd')
-rw-r--r-- | usr.sbin/nsd/udb.h | 26 | ||||
-rw-r--r-- | usr.sbin/nsd/udbzone.c | 47 | ||||
-rw-r--r-- | usr.sbin/nsd/udbzone.h | 12 |
3 files changed, 2 insertions, 83 deletions
diff --git a/usr.sbin/nsd/udb.h b/usr.sbin/nsd/udb.h index 049760dd961..de7985275c2 100644 --- a/usr.sbin/nsd/udb.h +++ b/usr.sbin/nsd/udb.h @@ -40,13 +40,10 @@ typedef struct udb_base udb_base; typedef struct udb_alloc udb_alloc; -/** these checks are very slow, disabled by default */ -#if 0 /** perform extra checks (when --enable-checking is used) */ #ifndef NDEBUG #define UDB_CHECK 1 #endif -#endif /** pointers are stored like this */ typedef uint64_t udb_void; @@ -144,7 +141,7 @@ struct udb_glob_d { uint64_t hsize; /** version number of this file */ uint8_t version; - /** was the file cleanly closed, 0 is not clean, 1 is clean */ + /** was the file not cleanly closed, 0 is ok */ uint8_t clean_close; /** an allocation operation was in progress, file needs to be salvaged * type enum udb_dirty_alloc */ @@ -204,11 +201,6 @@ struct udb_base { udb_walk_relptr_func* walkfunc; /** user data for walkfunc */ void* walkarg; - - /** compaction is inhibited */ - int inhibit_compact; - /** compaction is useful; deletions performed. */ - int useful_compact; }; typedef enum udb_chunk_type udb_chunk_type; @@ -554,22 +546,6 @@ udb_void udb_alloc_realloc(udb_alloc* alloc, udb_void r, size_t osz, */ int udb_alloc_grow(udb_alloc* alloc, size_t sz, size_t num); -/** - * attempt to compact the data and move free space to the end - * can shrink the db, which calls sync on the db (for portability). - * @param udb: the udb base. - * @return 0 on failure (to remap the (possibly) changed udb base). - */ -int udb_compact(udb_base* udb); - -/** - * set the udb to inhibit or uninhibit compaction. Does not perform - * the compaction itself if enabled, for that call udb_compact. - * @param udb: the udb base - * @param inhibit: 0 or 1. - */ -void udb_compact_inhibited(udb_base* udb, int inhibit); - /** * Set the alloc type for a newly alloced piece of data * @param alloc: the udb space allocator. diff --git a/usr.sbin/nsd/udbzone.c b/usr.sbin/nsd/udbzone.c index 67de2db94d1..bd5929b3929 100644 --- a/usr.sbin/nsd/udbzone.c +++ b/usr.sbin/nsd/udbzone.c @@ -22,7 +22,6 @@ udb_zone_delete_plain(udb_base* udb, udb_ptr* zone) udb_rptr_zero(&ZONE(zone)->node, udb); udb_rptr_zero(&ZONE(zone)->nsec3param, udb); udb_rptr_zero(&ZONE(zone)->log_str, udb); - udb_rptr_zero(&ZONE(zone)->file_str, udb); udb_ptr_new(&dtree, udb, &ZONE(zone)->domains); udb_rptr_zero(&ZONE(zone)->domains, udb); udb_radix_tree_delete(udb, &dtree); @@ -90,7 +89,6 @@ udb_zone_create(udb_base* udb, udb_ptr* result, const uint8_t* dname, udb_rel_ptr_init(&ZONE(&z)->domains); udb_rel_ptr_init(&ZONE(&z)->nsec3param); udb_rel_ptr_init(&ZONE(&z)->log_str); - udb_rel_ptr_init(&ZONE(&z)->file_str); ZONE(&z)->rrset_count = 0; ZONE(&z)->rr_count = 0; ZONE(&z)->expired = 0; @@ -207,7 +205,6 @@ udb_zone_clear(udb_base* udb, udb_ptr* zone) udb_ptr_new(&dtree, udb, &ZONE(zone)->domains); udb_rptr_zero(&ZONE(zone)->nsec3param, udb); udb_zone_set_log_str(udb, zone, NULL); - udb_zone_set_file_str(udb, zone, NULL); /* walk and delete all domains, rrsets, rrs, but keep tree */ for(udb_radix_first(udb, &dtree, &d); d.data; udb_radix_next(udb, &d)){ @@ -291,49 +288,6 @@ void udb_zone_set_log_str(udb_base* udb, udb_ptr* zone, const char* str) } } -void udb_zone_set_file_str(udb_base* udb, udb_ptr* zone, const char* str) -{ - /* delete original file str (if any) */ - if(ZONE(zone)->file_str.data) { - udb_ptr s; - size_t sz; - udb_ptr_new(&s, udb, &ZONE(zone)->file_str); - udb_rptr_zero(&ZONE(zone)->file_str, udb); - sz = strlen((char*)udb_ptr_data(&s))+1; - udb_ptr_free_space(&s, udb, sz); - } - - /* set new file str */ - if(str) { - udb_ptr s; - size_t sz = strlen(str)+1; - if(!udb_ptr_alloc_space(&s, udb, udb_chunk_type_data, sz)) { - return; /* failed to allocate file string */ - } - memmove(udb_ptr_data(&s), str, sz); - udb_rptr_set_ptr(&ZONE(zone)->file_str, udb, &s); - udb_ptr_unlink(&s, udb); - } -} - -const char* udb_zone_get_file_str(udb_base* udb, const uint8_t* dname, - size_t dlen) -{ - udb_ptr z; - if(udb_zone_search(udb, &z, dname, dlen)) { - const char* str; - if(ZONE(&z)->file_str.data) { - udb_ptr s; - udb_ptr_new(&s, udb, &ZONE(&z)->file_str); - str = (const char*)udb_ptr_data(&s); - udb_ptr_unlink(&s, udb); - } else str = NULL; - udb_ptr_unlink(&z, udb); - return str; - } - return NULL; -} - #ifdef NSEC3 /** select the nsec3param for nsec3 usage */ static void @@ -752,7 +706,6 @@ udb_zone_walk_chunk(void* base, void* d, uint64_t s, udb_walk_relptr_cb* cb, (*cb)(base, &p->domains, arg); (*cb)(base, &p->nsec3param, arg); (*cb)(base, &p->log_str, arg); - (*cb)(base, &p->file_str, arg); } void diff --git a/usr.sbin/nsd/udbzone.h b/usr.sbin/nsd/udbzone.h index eb81675a18b..f1163e4dfe5 100644 --- a/usr.sbin/nsd/udbzone.h +++ b/usr.sbin/nsd/udbzone.h @@ -15,10 +15,7 @@ * | * v * zonetree -> zone -- zone_name - * radtree |--> nsec3param - * |--> log_str - * |--> file_str - * | + * radtree | * v * domain --> rrset -> rr * radtree list list @@ -35,8 +32,6 @@ struct zone_d { udb_rel_ptr nsec3param; /** the log_str for the AXFR change, or 0 */ udb_rel_ptr log_str; - /** the file name when read from a file, or 0 */ - udb_rel_ptr file_str; /** modification time, time when the zone data was changed */ uint64_t mtime; /** number of RRsets in the zone */ @@ -110,11 +105,6 @@ int udb_zone_search(udb_base* udb, udb_ptr* result, const uint8_t* dname, uint64_t udb_zone_get_mtime(udb_base* udb, const uint8_t* dname, size_t dlen); /** set log str in udb, or remove it */ void udb_zone_set_log_str(udb_base* udb, udb_ptr* zone, const char* str); -/** set file str in udb, or remove it */ -void udb_zone_set_file_str(udb_base* udb, udb_ptr* zone, const char* str); -/** get file string for zone or NULL */ -const char* udb_zone_get_file_str(udb_base* udb, const uint8_t* dname, - size_t dlen); /** find a domain name in the zone domain tree */ int udb_domain_find(udb_base* udb, udb_ptr* zone, const uint8_t* nm, size_t nmlen, udb_ptr* result); |