This file contains the worker process or thread that performs the DNS resolving and validation. More...
#include "util/data/packed_rrset.h"| Data Structures | |
| struct | libworker | 
| The library-worker status structure Internal to the worker.  More... | |
| Functions | |
| int | libworker_bg (struct ub_ctx *ctx) | 
| Create a background worker. | |
| int | libworker_fg (struct ub_ctx *ctx, struct ctx_query *q) | 
| Create a foreground worker. | |
| struct libworker * | libworker_create_event (struct ub_ctx *ctx, struct ub_event_base *eb) | 
| create worker for event-based interface. | |
| int | libworker_attach_mesh (struct ub_ctx *ctx, struct ctx_query *q, int *async_id) | 
| Attach context_query to mesh for callback in event-driven setup. | |
| void | libworker_delete_event (struct libworker *w) | 
| delete worker for event-based interface. | |
| void | libworker_alloc_cleanup (void *arg) | 
| cleanup the cache to remove all rrset IDs from it, arg is libworker | |
| void | libworker_enter_result (struct ub_result *res, struct sldns_buffer *buf, struct regional *temp, enum sec_status msg_security) | 
| fill result from parsed message, on error fills servfail | |
This file contains the worker process or thread that performs the DNS resolving and validation.
The worker is called by a procedure and if in the background continues until exit, if in the foreground returns from the procedure when done.
| int libworker_bg | ( | struct ub_ctx * | ctx | ) | 
Create a background worker.
| ctx | is updated with pid/tid of the background worker. a new allocation cache is obtained from ctx. It contains the threadnumber and unique id for further (shared) cache insertions. | 
References ub_ctx::bg_pid, ub_ctx::bg_tid, ub_ctx::cfglock, libworker::ctx, ub_ctx::dothread, fatal_exit(), libworker::is_bg_thread, libworker_dobg(), libworker_setup(), ub_ctx::qq_pipe, ub_ctx::rr_pipe, libworker::thread_num, ub_ctx::thread_worker, tube_close_read(), tube_close_write(), UB_FORKFAIL, UB_NOERROR, and UB_NOMEM.
Referenced by ub_resolve_async().
Create a foreground worker.
This worker will join the threadpool of resolver threads. It exits when the query answer has been obtained (or error). This routine blocks until the worker is finished.
| ctx | new allocation cache obtained and returned to it. | 
| q | query (result is stored in here). | 
References module_env::auth_zones, auth_zones_downstream_answer(), libworker::back, libworker::base, BIT_RD, comm_base_dispatch(), libworker::ctx, ub_ctx::env, libworker::env, libworker_delete(), libworker_fg_done_cb(), libworker_fillup_fg(), libworker_setup(), ub_ctx::local_zones, local_zones_answer(), module_env::mesh, mesh_new_callback(), query_info::qname, regional_free_all(), module_env::scratch, sec_status_insecure, setup_qinfo_edns(), sldns_buffer_write_u16_at(), UB_INITFAIL, UB_NOERROR, UB_NOMEM, UB_SYNTAX, outside_network::udp_buff, and ctx_query::w.
Referenced by ub_resolve().
| struct libworker * libworker_create_event | ( | struct ub_ctx * | ctx, | 
| struct ub_event_base * | eb | ||
| ) | 
create worker for event-based interface.
| ctx | context with config. | 
| eb | event base. | 
References libworker::ctx, and libworker_setup().
Referenced by ub_resolve_event().
Attach context_query to mesh for callback in event-driven setup.
| ctx | context | 
| q | context query entry | 
| async_id | store query num if query takes long. | 
References module_env::auth_zones, auth_zones_downstream_answer(), libworker::back, BIT_RD, libworker::ctx, ub_ctx::env, libworker::env, ub_ctx::event_worker, libworker_event_done_cb(), ub_ctx::local_zones, local_zones_answer(), module_env::mesh, mesh_new_callback(), query_info::qname, ctx_query::querynum, regional_free_all(), module_env::scratch, sec_status_insecure, setup_qinfo_edns(), sldns_buffer_write_u16_at(), UB_INITFAIL, UB_NOERROR, UB_NOMEM, UB_SYNTAX, outside_network::udp_buff, and ctx_query::w.
Referenced by ub_resolve_event().
| void libworker_delete_event | ( | struct libworker * | w | ) | 
delete worker for event-based interface.
does not free the event_base.
| w | event-based worker to delete. | 
References libworker::base, comm_base_delete_no_base(), and libworker_delete_env().
Referenced by ub_ctx_delete(), and ub_ctx_set_event().
| void libworker_enter_result | ( | struct ub_result * | res, | 
| struct sldns_buffer * | buf, | ||
| struct regional * | temp, | ||
| enum sec_status | msg_security | ||
| ) | 
fill result from parsed message, on error fills servfail
| res | is clear at start, filled in at end. | 
| buf | contains DNS message. | 
| temp | temporary buffer for parse. | 
| msg_security | security status of the DNS message. On error, the res may contain a different status (out of memory is not secure, not bogus). | 
References ub_result::bogus, ub_result::data, fill_res(), reply_info::flags, FLAGS_GET_RCODE, ub_result::havedata, log_err(), ub_result::nxdomain, parse_reply_in_temp_region(), ub_result::rcode, reply_find_answer_rrset(), reply_find_final_cname_target(), sec_status_bogus, sec_status_secure, sec_status_secure_sentinel_fail, and ub_result::secure.
Referenced by libworker_fillup_fg(), and process_answer_detail().