From: W.C.A. Wijngaards Date: Wed, 1 Jul 2026 12:41:40 +0000 (+0200) Subject: - auth-load-thread, check for quit during the processing. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b5a03093f603272d9c3cc40f7f0b32316d050b5b;p=thirdparty%2Funbound.git - auth-load-thread, check for quit during the processing. --- diff --git a/services/authload.c b/services/authload.c index c42c129aa..6ba58ced5 100644 --- a/services/authload.c +++ b/services/authload.c @@ -159,14 +159,15 @@ auth_load_task_create_xfr(struct auth_xfer* xfr, struct worker* worker) return task; } -/** See if there is a quit signal, true if so. */ -static int +int auth_load_thread_poll_for_quit(struct auth_load_thread* thr) { int inevent, loopexit = 0; uint8_t cmd; ssize_t ret; + if(!thr) + return 0; if(thr->need_to_quit) return 1; /* Is there data? */ @@ -377,7 +378,7 @@ auth_load_process_http(struct auth_load_thread* thr) return 0; } if(!xfr_apply_http(task->name, task->namelen, task->host, task->file, - task->chunks_first, z, scratch_buffer)) { + task->chunks_first, z, scratch_buffer, thr)) { sldns_buffer_free(scratch_buffer); auth_zone_delete_proxy(z); return 0; @@ -505,7 +506,7 @@ auth_load_process_ixfr(struct auth_load_thread* thr) return 0; } if(!xfr_apply_ixfr(task->chunks_first, task->serial, z, - scratch_buffer)) { + scratch_buffer, thr)) { sldns_buffer_free(scratch_buffer); auth_zone_delete_proxy(z); return 0; @@ -548,7 +549,7 @@ auth_load_process_axfr(struct auth_load_thread* thr) return 0; } - if(!xfr_apply_axfr(task->chunks_first, z, scratch_buffer)) { + if(!xfr_apply_axfr(task->chunks_first, z, scratch_buffer, thr)) { sldns_buffer_free(scratch_buffer); auth_zone_delete_proxy(z); return 0; diff --git a/services/authload.h b/services/authload.h index d3f7a089f..7b884f933 100644 --- a/services/authload.h +++ b/services/authload.h @@ -156,4 +156,7 @@ struct auth_load_task { */ int auth_load_add_task_xfr(struct auth_xfer* xfr, struct worker* worker); +/** See if there is a quit signal, true if so. */ +int auth_load_thread_poll_for_quit(struct auth_load_thread* thr); + #endif /* SERVICES_AUTHLOAD_H */ diff --git a/services/authzone.c b/services/authzone.c index 5eb89c58a..fbc0b946e 100644 --- a/services/authzone.c +++ b/services/authzone.c @@ -4995,7 +4995,8 @@ ixfr_start_serial(struct auth_chunk* rr_chunk, int rr_num, size_t rr_pos, /** apply IXFR to zone in memory. z is locked. false on failure(mallocfail) */ int xfr_apply_ixfr(struct auth_chunk* chunk_list, uint32_t xfr_serial, - struct auth_zone* z, struct sldns_buffer* scratch_buffer) + struct auth_zone* z, struct sldns_buffer* scratch_buffer, + struct auth_load_thread* thr) { struct auth_chunk* rr_chunk; int rr_num; @@ -5121,6 +5122,10 @@ xfr_apply_ixfr(struct auth_chunk* chunk_list, uint32_t xfr_serial, } rr_counter++; + if(thr && rr_counter % 10000 == 0) { + if(auth_load_thread_poll_for_quit(thr)) + return 0; + } chunk_rrlist_gonext(&rr_chunk, &rr_num, &rr_pos, rr_nextpos); } if(softfail) { @@ -5138,13 +5143,13 @@ apply_ixfr(struct auth_xfer* xfr, struct auth_zone* z, xfr->num_ixfrs++; return xfr_apply_ixfr(xfr->task_transfer->chunks_first, xfr->serial, z, - scratch_buffer); + scratch_buffer, NULL); } /** apply AXFR to zone in memory. z is locked. false on failure(mallocfail) */ int xfr_apply_axfr(struct auth_chunk* chunk_list, struct auth_zone* z, - struct sldns_buffer* scratch_buffer) + struct sldns_buffer* scratch_buffer, struct auth_load_thread* thr) { struct auth_chunk* rr_chunk; int rr_num; @@ -5190,6 +5195,10 @@ xfr_apply_axfr(struct auth_chunk* chunk_list, struct auth_zone* z, } rr_counter++; + if(thr && rr_counter % 10000 == 0) { + if(auth_load_thread_poll_for_quit(thr)) + return 0; + } chunk_rrlist_gonext(&rr_chunk, &rr_num, &rr_pos, rr_nextpos); } if(!have_end_soa) { @@ -5211,7 +5220,7 @@ apply_axfr(struct auth_xfer* xfr, struct auth_zone* z, xfr->soa_zone_acquired = 0; xfr->num_ixfrs = 0; return xfr_apply_axfr(xfr->task_transfer->chunks_first, z, - scratch_buffer); + scratch_buffer, NULL); } void @@ -5254,7 +5263,7 @@ xfr_http_syntax_check(uint8_t* name, size_t namelen, uint16_t dclass, int xfr_apply_http(uint8_t* name, size_t namelen, const char* host, const char* file, struct auth_chunk* chunk_list, struct auth_zone* z, - struct sldns_buffer* scratch_buffer) + struct sldns_buffer* scratch_buffer, struct auth_load_thread* thr) { /* parse data in chunks */ /* parse RR's and read into memory. ignore $INCLUDE from the @@ -5279,6 +5288,10 @@ xfr_apply_http(uint8_t* name, size_t namelen, const char* host, /* process this line */ pstate.lineno++; chunkline_newline_removal(scratch_buffer); + if(thr && pstate.lineno % 10000 == 0) { + if(auth_load_thread_poll_for_quit(thr)) + return 0; + } if(chunkline_is_comment_line_or_empty(scratch_buffer)) { continue; } @@ -5330,7 +5343,7 @@ apply_http(struct auth_xfer* xfr, struct auth_zone* z, return xfr_apply_http(xfr->name, xfr->namelen, xfr->task_transfer->master->host, xfr->task_transfer->master->file, - xfr->task_transfer->chunks_first, z, scratch_buffer); + xfr->task_transfer->chunks_first, z, scratch_buffer, NULL); } /** write http chunks to zonefile to create downloaded file */ diff --git a/services/authzone.h b/services/authzone.h index 89e34eaa1..9d41e71da 100644 --- a/services/authzone.h +++ b/services/authzone.h @@ -65,6 +65,7 @@ struct auth_probe; struct auth_transfer; struct auth_master; struct auth_chunk; +struct auth_load_thread; /** * Authoritative zones, shared. @@ -879,14 +880,15 @@ int xfr_http_syntax_check(uint8_t* name, size_t namelen, uint16_t dclass, /** Apply http transfer to auth_zone */ int xfr_apply_http(uint8_t* name, size_t namelen, const char* host, const char* file, struct auth_chunk* chunk_list, struct auth_zone* z, - struct sldns_buffer* scratch_buffer); + struct sldns_buffer* scratch_buffer, struct auth_load_thread* thr); /** Apply IXFR transfer to auth_zone */ int xfr_apply_ixfr(struct auth_chunk* chunk_list, uint32_t xfr_serial, - struct auth_zone* z, struct sldns_buffer* scratch_buffer); + struct auth_zone* z, struct sldns_buffer* scratch_buffer, + struct auth_load_thread* thr); /** Apply AXFR transfer to auth_zone */ int xfr_apply_axfr(struct auth_chunk* chunk_list, struct auth_zone* z, - struct sldns_buffer* scratch_buffer); + struct sldns_buffer* scratch_buffer, struct auth_load_thread* thr); #endif /* SERVICES_AUTHZONE_H */