]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib/resolver: NULL out callback before call
authorDavid Lamparter <equinox@diac24.net>
Thu, 23 May 2019 12:25:58 +0000 (14:25 +0200)
committerDavid Lamparter <equinox@diac24.net>
Wed, 3 Jul 2019 15:15:38 +0000 (17:15 +0200)
The callback itself might want to reschedule the resolver, so it is
useful to clear out the callback field before making the call instead of
after.

Signed-off-by: David Lamparter <equinox@diac24.net>
lib/resolver.c

index 001c293df2f0ec19cc880a75ccfcc72d2e992f74..fb8aeed92f8de27a9e130c55d16a66eb8e81fcce 100644 (file)
@@ -145,14 +145,17 @@ static void ares_address_cb(void *arg, int status, int timeouts,
 {
        struct resolver_query *query = (struct resolver_query *)arg;
        union sockunion addr[16];
+       void (*callback)(struct resolver_query *, int, union sockunion *);
        size_t i;
 
+       callback = query->callback;
+       query->callback = NULL;
+
        if (status != ARES_SUCCESS) {
                if (resolver_debug)
                        zlog_debug("[%p] Resolving failed", query);
 
-               query->callback(query, -1, NULL);
-               query->callback = NULL;
+               callback(query, -1, NULL);
                return;
        }
 
@@ -174,8 +177,7 @@ static void ares_address_cb(void *arg, int status, int timeouts,
        if (resolver_debug)
                zlog_debug("[%p] Resolved with %d results", query, (int)i);
 
-       query->callback(query, i, &addr[0]);
-       query->callback = NULL;
+       callback(query, i, &addr[0]);
 }
 
 void resolver_resolve(struct resolver_query *query, int af,