34 #include <sys/types.h>
35 #include <sys/event.h>
99 #define lookup_timer(a) _lookup_timer(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
107 ast_log(
__LOG_ERROR, file, line, func,
"Couldn't find timer with handle %d\n", handle);
121 ast_log(
LOG_ERROR,
"Could not allocate memory for kqueue_timer structure\n");
124 if ((handle = kqueue()) < 0) {
151 struct timespec nowait = { 0, 1 };
153 struct kevent64_s kev;
155 EV_SET64(&kev, our_timer->
handle, EVFILT_TIMER, EV_ADD | EV_ENABLE, NOTE_NSECONDS,
157 kevent64(our_timer->
handle, &kev, 1, NULL, 0, 0, &nowait);
161 EV_SET(&kev, our_timer->
handle, EVFILT_TIMER, EV_ADD | EV_ENABLE,
163 nsecs <= 0xFFffFFff ? NOTE_NSECONDS :
172 nsecs <= 0xFFffFFff ? nsecs :
180 kevent(our_timer->
handle, &kev, 1, NULL, 0, &nowait);
206 if (our_timer->
unacked < quantity) {
207 ast_debug(1,
"Acking more events than have expired?!!\n");
212 our_timer->
unacked -= quantity;
253 struct timespec sixty_seconds = { 60, 0 };
262 if (kevent(handle, NULL, 0, &kev, 1, &sixty_seconds) > 0) {
263 our_timer->
unacked += kev.data;
281 #ifdef TEST_FRAMEWORK
286 struct pollfd pfd = { 0, POLLIN, 0 };
288 struct timeval start;
292 info->name =
"test_kqueue_timing";
293 info->category =
"/res/res_timing_kqueue/";
294 info->summary =
"Test KQueue timing interface";
295 info->description =
"Verify that the KQueue timing interface correctly generates timing events";
318 if (pfd.revents != POLLIN) {
319 ast_test_status_update(test,
"poll() should have returned POLLIN, but instead returned %hd\n", pfd.revents);
342 for (i = 0; i < 100; i++) {
390 kqueue_timers = NULL;
static int kqueue_timer_disable_continuous(int handle)
static enum ast_timer_event kqueue_timer_get_event(int handle)
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_link(arg1, arg2)
static int kqueue_timer_open(void)
static void timer_destroy(void *obj)
static struct ast_timing_interface kqueue_timing
Time-related functions and macros.
int ast_unregister_timing_interface(void *handle)
Unregister a previously registered timing interface.
static unsigned int kqueue_timer_get_max_rate(int handle)
#define AST_TEST_REGISTER(cb)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
static int kqueue_timer_ack(int handle, unsigned int quantity)
static struct kqueue_timer * _lookup_timer(int handle, const char *file, int line, const char *func)
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_test_status_update(a, b, c...)
static int kqueue_timer_enable_continuous(int handle)
#define ast_poll(a, b, c)
#define ao2_ref(o, delta)
static int kqueue_timer_cmp(void *obj, void *args, int flags)
static int load_module(void)
static int kqueue_timer_set_rate(int handle, unsigned int rate)
static int kqueue_timer_hash(const void *obj, const int flags)
#define AST_TEST_UNREGISTER(cb)
static void * timing_funcs_handle
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
#define ao2_alloc(data_size, destructor_fn)
#define ao2_find(arg1, arg2, arg3)
Support for logging to various files, console and syslog Configuration in file logger.conf.
static void kqueue_set_nsecs(struct kqueue_timer *our_timer, uint64_t nsecs)
#define ao2_container_alloc(arg1, arg2, arg3)
#define AST_TEST_DEFINE(hdr)
#define ast_register_timing_interface(i)
Register a set of timing functions.
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
static int unload_module(void)
#define ASTERISK_GPL_KEY
The text the key() function should return.
static struct ast_timer * timer
Asterisk module definitions.
static struct ao2_container * kqueue_timers
#define ao2_unlink(arg1, arg2)
static void kqueue_timer_close(int handle)
Timing source management.
unsigned int is_continuous