]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- auth-load-thread, check for quit during the processing.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 1 Jul 2026 12:41:40 +0000 (14:41 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 1 Jul 2026 12:41:40 +0000 (14:41 +0200)
services/authload.c
services/authload.h
services/authzone.c
services/authzone.h

index c42c129aae699c938216c4d4e17d748e0c035379..6ba58ced5bd0d49f81203a14056a6b34df08f18a 100644 (file)
@@ -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;
index d3f7a089fe9bc4ecd864689e604982f7b3f08d6b..7b884f933f0c93f7bd70dc1b4df8b683e33f04cd 100644 (file)
@@ -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 */
index 5eb89c58a5a294927a1a40a8b996e83ba98258a0..fbc0b946eb799edb03aa8edb3c614ff55dd3ee51 100644 (file)
@@ -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 */
index 89e34eaa1885b74cc3d235ad655dd3e66def1677..9d41e71da7fb187da83acfb46462d6f87472ee63 100644 (file)
@@ -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 */