diff options
| author | David Lamparter <equinox@diac24.net> | 2019-05-23 14:25:58 +0200 |
|---|---|---|
| committer | David Lamparter <equinox@diac24.net> | 2019-07-03 17:15:38 +0200 |
| commit | 50cdb6cf95c5fc7df40e4a7328eb1fc7fcff4a9c (patch) | |
| tree | 52bd79e4ed4d0d0c7de8bc563ee4b2e8f0753240 | |
| parent | fe9e7b71cf0930db1f8d6872f415466689511885 (diff) | |
lib/resolver: NULL out callback before call
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>
| -rw-r--r-- | lib/resolver.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/resolver.c b/lib/resolver.c index 001c293df2..fb8aeed92f 100644 --- a/lib/resolver.c +++ b/lib/resolver.c @@ -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, |
