mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-11 05:14:46 -04:00
test/dns: more graceful coverage of @fail_requests
In case when evdns_base_free() called with @fail_requests, we can potentially have leaks, but we can avoid them if we will run event loop once again to trigger defer cbs, so let's do this, instead of magical decrements (and also this will give an example how to avoid leaks for evdns).
This commit is contained in:
parent
fdf713a08b
commit
123d372864
@ -1902,29 +1902,22 @@ dbg_leak_resume(void *env_, int cancel, int send_err_shutdown)
|
||||
tt_assert(!evdns_base_resume(env->dns_base));
|
||||
}
|
||||
|
||||
event_base_loop(env->base, EVLOOP_NONBLOCK);
|
||||
/**
|
||||
* Because we don't cancel request,
|
||||
* and want our callback to recieve DNS_ERR_SHUTDOWN,
|
||||
* we use deferred callback, and there was
|
||||
* Because we don't cancel request, and want our callback to recieve
|
||||
* DNS_ERR_SHUTDOWN, we use deferred callback, and there was:
|
||||
* - one extra malloc(),
|
||||
* @see reply_schedule_callback()
|
||||
* - and one missing free
|
||||
* @see request_finished() (req->handle->pending_cb = 1)
|
||||
* than we don't need to count in testleak_cleanup()
|
||||
*
|
||||
* So just decrement allocated_chunks to 2,
|
||||
* like we already take care about it.
|
||||
* than we don't need to count in testleak_cleanup(), but we can clean them
|
||||
* if we will run loop once again, but *after* evdns base freed.
|
||||
*/
|
||||
if (!cancel && send_err_shutdown) {
|
||||
allocated_chunks -= 2;
|
||||
}
|
||||
|
||||
evdns_base_free(env->dns_base, send_err_shutdown);
|
||||
env->dns_base = 0;
|
||||
event_base_loop(env->base, EVLOOP_NONBLOCK);
|
||||
|
||||
end:
|
||||
evdns_base_free(env->dns_base, send_err_shutdown);
|
||||
env->dns_base = 0;
|
||||
|
||||
event_base_free(env->base);
|
||||
env->base = 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user