]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
fixup! Use lock-free hashtable for storing resolver fetch contexts
authorOndřej Surý <ondrej@isc.org>
Tue, 23 Sep 2025 10:04:35 +0000 (12:04 +0200)
committerOndřej Surý <ondrej@isc.org>
Tue, 23 Sep 2025 22:08:21 +0000 (00:08 +0200)
lib/dns/resolver.c

index cf4f465c01afa5911673ce1c3ff273d53bdb9d2f..37c8507dc7ea75a32c164c039c9b641682b68eb6 100644 (file)
@@ -687,7 +687,7 @@ findnoqname(fetchctx_t *fctx, dns_message_t *message, dns_name_t *name,
        rcu_read_lock();                                                \
        if (fctx__done(*fctxp, result, __func__, __FILE__, __LINE__)) { \
                fetchctx_detach(fctxp);                                 \
-       };                                                              \
+       }                                                               \
        rcu_read_unlock()
 
 #define fctx_failure_unref(fctx, result)                              \
@@ -695,35 +695,39 @@ findnoqname(fetchctx_t *fctx, dns_message_t *message, dns_name_t *name,
        rcu_read_lock();                                              \
        if (fctx__done(fctx, result, __func__, __FILE__, __LINE__)) { \
                fetchctx_unref(fctx);                                 \
-       };                                                            \
+       }                                                             \
        rcu_read_unlock()
 
 #define fctx_success_detach(fctxp)                                             \
        rcu_read_lock();                                                       \
        if (fctx__done(*fctxp, ISC_R_SUCCESS, __func__, __FILE__, __LINE__)) { \
                fetchctx_detach(fctxp);                                        \
-       };                                                                     \
+       }                                                                      \
        rcu_read_unlock()
 
 #define fctx_success_unref(fctx)                                             \
        rcu_read_lock();                                                     \
        if (fctx__done(fctx, ISC_R_SUCCESS, __func__, __FILE__, __LINE__)) { \
                fetchctx_unref(fctx);                                        \
-       };                                                                   \
+       }                                                                    \
        rcu_read_unlock()
 
 static bool
+fetchctx_ref_unless_zero(fetchctx_t *fctx) {
+       return urcu_ref_get_unless_zero(&fctx->ref);
+}
+
+static void
 fetchctx_attach(fetchctx_t *fctx, fetchctx_t **fctxp) {
-       if (urcu_ref_get_unless_zero(&fctx->ref)) {
-               *fctxp = fctx;
-               return true;
-       }
-       return false;
+       bool ref = fetchctx_ref_unless_zero(fctx);
+       INSIST(ref == true);
+       *fctxp = fctx;
 }
 
-static bool
+static void
 fetchctx_ref(fetchctx_t *fctx) {
-       return urcu_ref_get_unless_zero(&fctx->ref);
+       bool ref = fetchctx_ref_unless_zero(fctx);
+       INSIST(ref == true);
 }
 
 static void
@@ -10004,7 +10008,7 @@ get_attached_fctx(dns_resolver_t *res, isc_loop_t *loop, const dns_name_t *name,
                LOCK(&fctx->lock);
        }
 
-       if (!fetchctx_ref(fctx)) {
+       if (!fetchctx_ref_unless_zero(fctx)) {
                UNLOCK(&fctx->lock);
                fctx = NULL;
                goto create;