33 #include <sys/timerfd.h>
68 #define TIMERFD_TIMER_BUCKETS 563
69 #define TIMERFD_MAX_RATE 1000
103 ast_log(
LOG_ERROR,
"Could not allocate memory for timerfd_timer structure\n");
106 if ((handle = timerfd_create(CLOCK_MONOTONIC, 0)) < 0) {
158 our_timer->
saved_timer.it_value.tv_nsec = rate ? (long) (1000000000 / rate) : 0L;
163 res = timerfd_settime(handle, 0, &our_timer->
saved_timer, NULL);
174 uint64_t expirations;
194 struct itimerspec timer_status;
196 if (timerfd_gettime(handle, &timer_status)) {
197 ast_log(
LOG_ERROR,
"Call to timerfd_gettime() using handle %d error: %s\n", handle, strerror(
errno));
203 if (timer_status.it_value.tv_sec == 0 && timer_status.it_value.tv_nsec == 0) {
204 ast_debug(1,
"Avoiding read on disarmed timerfd %d\n", handle);
209 read_result = read(handle, &expirations,
sizeof(expirations));
210 if (read_result == -1) {
219 }
while (read_result !=
sizeof(expirations));
224 if (expirations != quantity) {
225 ast_debug(2,
"Expected to acknowledge %u ticks but got %llu instead\n", quantity, (
unsigned long long) expirations);
233 struct itimerspec continuous_timer = {
234 .it_value.tv_nsec = 1L,
260 res = timerfd_settime(handle, 0, &continuous_timer, &our_timer->
saved_timer);
294 res = timerfd_settime(handle, 0, &our_timer->
saved_timer, NULL);
341 if ((fd = timerfd_create(CLOCK_MONOTONIC, 0)) < 0) {
342 ast_log(
LOG_ERROR,
"timerfd_create() not supported by the kernel. Not loading.\n");
366 timerfd_timers = NULL;
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_link(arg1, arg2)
static int timerfd_timer_disable_continuous(int handle)
static void timerfd_timer_close(int handle)
Time-related functions and macros.
int ast_unregister_timing_interface(void *handle)
Unregister a previously registered timing interface.
static int timerfd_timer_hash(const void *obj, const int flags)
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
static int load_module(void)
static void * timing_funcs_handle
static struct ast_timing_interface timerfd_timing
static int timerfd_timer_enable_continuous(int handle)
#define ast_debug(level,...)
Log a DEBUG message.
static struct ao2_container * timerfd_timers
unsigned int is_continuous
struct itimerspec saved_timer
#define ao2_ref(o, delta)
static int timerfd_timer_open(void)
static unsigned int timerfd_timer_get_max_rate(int 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)
static int unload_module(void)
Support for logging to various files, console and syslog Configuration in file logger.conf.
static int timerfd_timer_cmp(void *obj, void *args, int flags)
#define TIMERFD_TIMER_BUCKETS
#define ao2_container_alloc(arg1, arg2, arg3)
static void timer_destroy(void *obj)
#define ast_register_timing_interface(i)
Register a set of timing functions.
static enum ast_timer_event timerfd_timer_get_event(int handle)
#define ASTERISK_GPL_KEY
The text the key() function should return.
static struct ast_timer * timer
static int timerfd_timer_ack(int handle, unsigned int quantity)
Asterisk module definitions.
#define ao2_unlink(arg1, arg2)
Timing source management.
static int timerfd_timer_set_rate(int handle, unsigned int rate)