/*
* Copyright (C) 1999-2002, 2004, 2005, 2007, 2012, 2014-2017 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*! \file */
#include <config.h>
#include <isc/ratelimiter.h>
typedef enum {
struct isc_ratelimiter {
int refs;
};
static void
static void
{
return ISC_R_NOMEMORY;
if (result != ISC_R_SUCCESS)
goto free_mem;
if (result != ISC_R_SUCCESS)
goto free_mutex;
/*
* Increment the reference count to indicate that we may
* (soon) have events outstanding.
*/
sizeof(isc_event_t),
*ratelimiterp = rl;
return (ISC_R_SUCCESS);
return (result);
}
/*
* If the timer is currently running, change its rate.
*/
}
return (result);
}
void
if (pertic == 0)
pertic = 1;
}
void
}
{
else
if (result == ISC_R_SUCCESS) {
}
} else {
}
return (result);
}
} else
return (result);
}
static void
isc_event_t *p;
while (pertic != 0) {
pertic--;
if (p != NULL) {
/*
* There is work to do. Let's do it after unlocking.
*/
} else {
/*
* No work left to do. Stop the timer so that we don't
* waste resources by having it fire periodically.
*/
pertic = 0; /* Force the loop to exit. */
}
if (p != NULL) {
isc_task_send(evtask, &p);
}
}
}
void
}
/*
* Send an event to our task. The delivery of this event
* indicates that no more timer events will be delivered.
*/
}
static void
}
static void
}
void
}
void
if (free_now)
}
break;
/* FALLTHROUGH */
case isc_ratelimiter_idle:
case isc_ratelimiter_stalled:
break;
}
return (result);
}
break;
case isc_ratelimiter_stalled:
if (result == ISC_R_SUCCESS)
} else
break;
case isc_ratelimiter_idle:
break;
}
return (result);
}