worker.c (c3b38330) | worker.c (550cf4a9) |
---|---|
1/* 2 * daemon/worker.c - worker that handles a pending list of requests. 3 * 4 * Copyright (c) 2007, NLnet Labs. All rights reserved. 5 * 6 * This software is open source. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 646 unchanged lines hidden (view full) --- 655 } 656 /* check CNAME chain (if any) */ 657 if(rep->an_numrrsets > 0 && (rep->rrsets[0]->rk.type == 658 htons(LDNS_RR_TYPE_CNAME) || rep->rrsets[0]->rk.type == 659 htons(LDNS_RR_TYPE_DNAME))) { 660 if(!reply_check_cname_chain(qinfo, rep)) { 661 /* cname chain invalid, redo iterator steps */ 662 verbose(VERB_ALGO, "Cache reply: cname chain broken"); | 1/* 2 * daemon/worker.c - worker that handles a pending list of requests. 3 * 4 * Copyright (c) 2007, NLnet Labs. All rights reserved. 5 * 6 * This software is open source. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 646 unchanged lines hidden (view full) --- 655 } 656 /* check CNAME chain (if any) */ 657 if(rep->an_numrrsets > 0 && (rep->rrsets[0]->rk.type == 658 htons(LDNS_RR_TYPE_CNAME) || rep->rrsets[0]->rk.type == 659 htons(LDNS_RR_TYPE_DNAME))) { 660 if(!reply_check_cname_chain(qinfo, rep)) { 661 /* cname chain invalid, redo iterator steps */ 662 verbose(VERB_ALGO, "Cache reply: cname chain broken"); |
663 bail_out: 664 rrset_array_unlock_touch(worker->env.rrset_cache, 665 worker->scratchpad, rep->ref, rep->rrset_count); 666 return 0; | 663 goto bail_out; |
667 } 668 } 669 /* check security status of the cached answer */ 670 if(must_validate && (rep->security == sec_status_bogus || 671 rep->security == sec_status_secure_sentinel_fail)) { 672 /* BAD cached */ 673 edns->edns_version = EDNS_ADVERTISED_VERSION; 674 edns->udp_size = EDNS_ADVERTISED_SIZE; --- 78 unchanged lines hidden (view full) --- 753 rrset_array_unlock_touch(worker->env.rrset_cache, worker->scratchpad, 754 rep->ref, rep->rrset_count); 755 if(worker->stats.extended) { 756 if(secure) worker->stats.ans_secure++; 757 server_stats_insrcode(&worker->stats, repinfo->c->buffer); 758 } 759 /* go and return this buffer to the client */ 760 return 1; | 664 } 665 } 666 /* check security status of the cached answer */ 667 if(must_validate && (rep->security == sec_status_bogus || 668 rep->security == sec_status_secure_sentinel_fail)) { 669 /* BAD cached */ 670 edns->edns_version = EDNS_ADVERTISED_VERSION; 671 edns->udp_size = EDNS_ADVERTISED_SIZE; --- 78 unchanged lines hidden (view full) --- 750 rrset_array_unlock_touch(worker->env.rrset_cache, worker->scratchpad, 751 rep->ref, rep->rrset_count); 752 if(worker->stats.extended) { 753 if(secure) worker->stats.ans_secure++; 754 server_stats_insrcode(&worker->stats, repinfo->c->buffer); 755 } 756 /* go and return this buffer to the client */ 757 return 1; |
758 759bail_out: 760 rrset_array_unlock_touch(worker->env.rrset_cache, 761 worker->scratchpad, rep->ref, rep->rrset_count); 762 return 0; |
|
761} 762 763/** Reply to client and perform prefetch to keep cache up to date. 764 * If the buffer for the reply is empty, it indicates that only prefetch is 765 * necessary and the reply should be suppressed (because it's dropped or 766 * being deferred). */ 767static void 768reply_and_prefetch(struct worker* worker, struct query_info* qinfo, 769 uint16_t flags, struct comm_reply* repinfo, time_t leeway) 770{ 771 /* first send answer to client to keep its latency 772 * as small as a cachereply */ | 763} 764 765/** Reply to client and perform prefetch to keep cache up to date. 766 * If the buffer for the reply is empty, it indicates that only prefetch is 767 * necessary and the reply should be suppressed (because it's dropped or 768 * being deferred). */ 769static void 770reply_and_prefetch(struct worker* worker, struct query_info* qinfo, 771 uint16_t flags, struct comm_reply* repinfo, time_t leeway) 772{ 773 /* first send answer to client to keep its latency 774 * as small as a cachereply */ |
773 if(sldns_buffer_limit(repinfo->c->buffer) != 0) | 775 if(sldns_buffer_limit(repinfo->c->buffer) != 0) { 776 if(repinfo->c->tcp_req_info) { 777 sldns_buffer_copy( 778 repinfo->c->tcp_req_info->spool_buffer, 779 repinfo->c->buffer); 780 } |
774 comm_point_send_reply(repinfo); | 781 comm_point_send_reply(repinfo); |
782 } |
|
775 server_stats_prefetch(&worker->stats, worker); 776 777 /* create the prefetch in the mesh as a normal lookup without 778 * client addrs waiting, which has the cache blacklisted (to bypass 779 * the cache and go to the network for the data). */ 780 /* this (potentially) runs the mesh for the new query */ 781 mesh_new_prefetch(worker->env.mesh, qinfo, flags, leeway + 782 PREFETCH_EXPIRY_ADD); --- 1278 unchanged lines hidden --- | 783 server_stats_prefetch(&worker->stats, worker); 784 785 /* create the prefetch in the mesh as a normal lookup without 786 * client addrs waiting, which has the cache blacklisted (to bypass 787 * the cache and go to the network for the data). */ 788 /* this (potentially) runs the mesh for the new query */ 789 mesh_new_prefetch(worker->env.mesh, qinfo, flags, leeway + 790 PREFETCH_EXPIRY_ADD); --- 1278 unchanged lines hidden --- |