2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

Fix small problems in the isc_ratelimiter

This commit is contained in:
Ondřej Surý 2022-09-29 18:06:05 +02:00
parent 1e2ededb07
commit 09b50d2237
No known key found for this signature in database
GPG Key ID: 2820F37E873DEA41

View File

@ -57,10 +57,13 @@ ratelimiter_tick(void *arg);
isc_result_t
isc_ratelimiter_create(isc_loop_t *loop, isc_ratelimiter_t **ratelimiterp) {
isc_ratelimiter_t *rl = NULL;
isc_mem_t *mctx = isc_loop_getmctx(loop);
isc_mem_t *mctx;
INSIST(loop != NULL);
INSIST(ratelimiterp != NULL && *ratelimiterp == NULL);
mctx = isc_loop_getmctx(loop);
rl = isc_mem_get(mctx, sizeof(*rl));
*rl = (isc_ratelimiter_t){
.pertic = 1,
@ -237,14 +240,16 @@ isc_ratelimiter_shutdown(isc_ratelimiter_t *rl) {
REQUIRE(VALID_RATELIMITER(rl));
LOCK(&rl->lock);
rl->state = isc_ratelimiter_shuttingdown;
if (rl->state != isc_ratelimiter_shuttingdown) {
rl->state = isc_ratelimiter_shuttingdown;
while ((event = ISC_LIST_HEAD(rl->pending)) != NULL) {
ISC_LIST_UNLINK(rl->pending, event, ev_ratelink);
event->ev_attributes |= ISC_EVENTATTR_CANCELED;
isc_task_send(event->ev_sender, &event);
while ((event = ISC_LIST_HEAD(rl->pending)) != NULL) {
ISC_LIST_UNLINK(rl->pending, event, ev_ratelink);
event->ev_attributes |= ISC_EVENTATTR_CANCELED;
isc_task_send(event->ev_sender, &event);
}
isc_loop_detach(&rl->loop);
}
isc_loop_detach(&rl->loop);
UNLOCK(&rl->lock);
}