Skip to content
Snippets Groups Projects

improved zonedb search, fixed root zone case + basic unit tests #242

Merged Ghost User requested to merge zonedb_refactor into master

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 1563 typedef struct {
    1564 const struct conf_t *config;
    1564 1565 knot_nameserver_t *ns;
    1565 1566 knot_zonedb_t *db_new;
    1566 1567 pthread_mutex_t lock;
    1567 int inserted;
    1568 unsigned qhead;
    1569 unsigned qtail;
    1570 conf_zone_t *q[];
    1571
    1572 };
    1568 } zone_loader_ctx_t;
    1573 1569
    1574 1570 /*! Thread entrypoint for loading zones. */
    1575 static int zonewalker(dthread_t *thread)
    1571 static int zones_loader_thread(dthread_t *thread)
  • 1729 1688 * if the pointers match, remove the zone from old DB
    1730 1689 */
    1731 /*! \todo Find better way of removing zone with given pointer.*/
    1732 knot_zone_t *new_zone = (knot_zone_t *)(*hattrie_iter_val(i));
    1733 knot_zone_t *old_zone = knot_zonedb_find_zone(
    1734 db_old, knot_zone_name(new_zone));
    1735 if (old_zone == new_zone) {
    1736 dbg_zones_exec(
    1737 char *name = knot_dname_to_str(knot_zone_name(old_zone));
    1738 dbg_zones_verb("zones: zone pointers match, removing zone %s "
    1739 "from database.\n", name);
    1740 free(name);
    1741 );
    1742
    1690 old_zone = knot_zonedb_find_zone(db_old, knot_zone_name(new_zones[i]));
    1691 if (old_zone == new_zones[i]) {
  • 585 585
    586 586 bool knot_dname_is_equal(const knot_dname_t *d1, const knot_dname_t *d2)
    587 587 {
    588 /*! \todo Could be implemented more efficiently, check profile first. */
  • 65 /* Name with more labels goes first. */
    66 return b_labels - a_labels;
    67 }
    68
    69 /*! \brief Find an equal name in sorted array (binary search). */
    70 #define ZONEDB_LEQ(arr,i,x) (knot_zonedb_cmp(((arr)[i])->name, (x)) <= 0)
    71 static long knot_zonedb_binsearch(knot_zone_t **arr, unsigned count,
    72 const knot_dname_t *name)
    73 {
    74 int k = BIN_SEARCH_FIRST_GE_CMP(arr, count, ZONEDB_LEQ, name) - 1;
    75 if (k > -1 && knot_dname_is_equal(arr[k]->name, name)) {
    76 return k;
    77 }
    78
    79 return -1;
    80
  • 35 110 /* API functions */
    36 111 /*----------------------------------------------------------------------------*/
    37 112
    38 knot_zonedb_t *knot_zonedb_new()
    113 knot_zonedb_t *knot_zonedb_new(unsigned size)
    39 114 {
    40 knot_zonedb_t *db =
    41 (knot_zonedb_t *)malloc(sizeof(knot_zonedb_t));
    115 knot_zonedb_t *db = malloc(sizeof(knot_zonedb_t));
    42 116 CHECK_ALLOC_LOG(db, NULL);
    43 117
    44 db->zone_tree = hattrie_create();
    45 if (db->zone_tree == NULL) {
    118 memset(db, 0, sizeof(knot_zonedb_t));
    119 db->reserved = size;
    120 db->array = malloc(size * sizeof(knot_zone_t*));
  • 148 272 knot_zone_contents_t *knot_zonedb_expire_zone(knot_zonedb_t *db,
    149 273 const knot_dname_t *zone_name)
    150 274 {
    275
  • The rest look fine.

  • Author Contributor

    Checked & fixed what's relevant, please review again. :100:

  • Looks good. :cat:

  • Please register or sign in to reply
    Loading