void covertests(ldns_rr_list *list, ldns_rdf *qname) { size_t i; ldns_rdf *smaller = qname; ldns_rdf *wcard = ldns_dname_new_frm_str("*"); for(i=0; i<ldns_dname_label_count(qname)+1; ++i) { check_cover(list, smaller); ldns_rdf* wcardchild = ldns_dname_cat_clone(wcard, smaller); check_cover(list, wcardchild); smaller = ldns_dname_left_chop(smaller); } /* check covers by weird names */ if(0) { check_cover(list, ldns_dname_new_frm_str("x.bar.example.")); check_cover(list, ldns_dname_new_frm_str("bar.example.")); } }
// Check whether this cmd(cmd_id) // conflicts with either of all the ISSUED cmds. static unsigned check_issue_conflict(uint64_t cmd_id){ unsigned conflict_flag = 0; for (int i = 0; i < QUEUE_NUM; i++){ for (int j = 0; j < ISSUE_BUF_SIZE; j++){ if (issue_buf[i].issue_queue[j].io_completed) continue; if (check_cover(issue_buf[i].issue_queue[j].cmd_id, cmd_id)) conflict_flag = 1; } if (conflict_flag) return 1; } return 0; }
// Check whether this cmd(cmd_id) // conflicts with either the ISSUE_BUF // or the PENDING_QUEUE. static unsigned check_conflict(uint64_t cmd_id){ if (check_issue_conflict(cmd_id)) return 1; // Check pending queue first. struct pending_task *target = master_pending.head; while (target){ if (check_cover(target->cmd_id, cmd_id)) return 1; target = target->next; } return 0; // Check issue_buf. //return check_issue_conflict(cmd_id); }
// Clear the pending queue. static void clear_pending(void){ if (master_pending.cnt == 0) return; int cnt = 0; struct pending_task *target = master_pending.head; while (target){ int cflag = 0; uint64_t cmd_id = master_pending.head->cmd_id; // If head cmd still cannot issue, just return if (check_issue_conflict(cmd_id)) cflag = 1; if (!cflag){ struct pending_task *cp_ptr = master_pending.head; while (cp_ptr != target){ if (check_cover(cp_ptr->cmd_id, cmd_id)){ cflag = 1; break; } cp_ptr = cp_ptr->next; } } if (cflag){ target = target -> next; continue; } cnt += 1; // Here we issue first so that // the worker would receive all the cmds from the buf. int rc = select_worker(); master_issue(cmd_id, rc); master_pending.cnt -= 1; struct pending_task *back_target = target->next; if (target->prev) target->prev->next = target->next; if (target->next) target->next->prev = target->prev; if (target == master_pending.head) master_pending.head = target->next; if (target == master_pending.tail) master_pending.tail = target->prev; free(target); target = back_target; } }