ratelimiter.c revision e0f1d72aa5d22752f2e7b18ece70d4c890cc4c19
/*
* Copyright (C) 1999, 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#include <config.h>
#include <isc/assertions.h>
#include <isc/ratelimiter.h>
struct isc_ratelimiter {
isc_task_t * task;
isc_timer_t * timer;
};
{
return ISC_R_NOMEMORY;
if (result != ISC_R_SUCCESS)
goto free_mem;
if (result != ISC_R_SUCCESS)
goto free_mutex;
*ratelimiterp = rl;
return (ISC_R_SUCCESS);
return (result);
}
/*
* If the timer is currently running, change its rate.
*/
}
return (result);
}
} else {
if (result == ISC_R_SUCCESS)
}
return (result);
}
static void
isc_event_t *p;
(void) task; /* Unused */
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.
*/
}
/*
* If we have an event, dispatch it.
* There is potential for optimization here since
* we are already executing in the context of "task".
*/
if (p != NULL)
}
void
isc_event_t *p;
isc_event_free(&p);
}
*ratelimiterp = NULL;
}