]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix that libunbound pipe functions fail with error after
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 16 Jun 2026 08:44:41 +0000 (10:44 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 16 Jun 2026 08:44:41 +0000 (10:44 +0200)
  an event base is set. Thanks to Qifan Zhang, Palo Alto
  Networks, for the report.

doc/Changelog
libunbound/libunbound.c

index 0bcd8a1824e51639b6db1dc69f3b7a771ae5ae98..0ecba8b5d0a1b658c5d4389e879c392890d41abf 100644 (file)
@@ -38,6 +38,9 @@
          Alto Networks, for the report.
        - Fix locking in libunbound ub_ctx_set_event call.
          Thanks to Qifan Zhang, Palo Alto Networks, for the report.
+       - Fix that libunbound pipe functions fail with error after
+         an event base is set. Thanks to Qifan Zhang, Palo Alto
+         Networks, for the report.
 
 15 June 2026: Wouter
        - Fix to add `max-transfer-size` and `max-transfer-time` that
index 8431b6bb11caba64422a1b835879347940691766..140a4523395d6e8ec4e9417bc211aae88fcbb45a 100644 (file)
@@ -571,6 +571,8 @@ ub_ctx_async(struct ub_ctx* ctx, int dothread)
 int 
 ub_poll(struct ub_ctx* ctx)
 {
+       if(!ctx || ctx->event_base)
+               return UB_INITFAIL;
        /* no need to hold lock while testing for readability. */
        return tube_poll(ctx->rr_pipe);
 }
@@ -578,6 +580,8 @@ ub_poll(struct ub_ctx* ctx)
 int 
 ub_fd(struct ub_ctx* ctx)
 {
+       if(!ctx || ctx->event_base)
+               return -1;
        return tube_read_fd(ctx->rr_pipe);
 }
 
@@ -672,6 +676,8 @@ ub_process(struct ub_ctx* ctx)
        int r;
        uint8_t* msg;
        uint32_t len;
+       if(!ctx || ctx->event_base)
+               return UB_INITFAIL;
        while(1) {
                msg = NULL;
                lock_basic_lock(&ctx->rrpipe_lock);
@@ -700,6 +706,8 @@ ub_wait(struct ub_ctx* ctx)
        int r;
        uint8_t* msg;
        uint32_t len;
+       if(!ctx || ctx->event_base)
+               return UB_INITFAIL;
        /* this is basically the same loop as _process(), but with changes.
         * holds the rrpipe lock and waits with tube_wait */
        while(1) {
@@ -837,6 +845,8 @@ ub_resolve_async(struct ub_ctx* ctx, const char* name, int rrtype,
        struct ctx_query* q;
        uint8_t* msg = NULL;
        uint32_t len = 0;
+       if(!ctx || ctx->event_base)
+               return UB_INITFAIL;
 
        if(async_id)
                *async_id = 0;