33 #include <sys/timerfd.h> 68 #define TIMERFD_MAX_RATE 1000 89 ast_log(
LOG_ERROR,
"Could not allocate memory for timerfd_timer structure\n");
92 if ((timer->
fd = timerfd_create(CLOCK_MONOTONIC, 0)) < 0) {
114 timer->
saved_timer.it_value.tv_nsec = rate ? (long) (1000000000 / rate) : 0L;
130 uint64_t expirations;
137 struct itimerspec timer_status;
139 if (timerfd_gettime(timer->
fd, &timer_status)) {
146 if (timer_status.it_value.tv_sec == 0 && timer_status.it_value.tv_nsec == 0) {
147 ast_debug(1,
"Avoiding read on disarmed timerfd %d\n", timer->
fd);
152 read_result = read(timer->
fd, &expirations,
sizeof(expirations));
153 if (read_result == -1) {
162 }
while (read_result !=
sizeof(expirations));
166 if (expirations != quantity) {
167 ast_debug(2,
"Expected to acknowledge %u ticks but got %llu instead\n", quantity, (
unsigned long long) expirations);
177 static const struct itimerspec continuous_timer = {
178 .it_value.tv_nsec = 1L,
191 res = timerfd_settime(timer->
fd, 0, &continuous_timer, &timer->
saved_timer);
256 if ((fd = timerfd_create(CLOCK_MONOTONIC, 0)) < 0) {
257 ast_log(
LOG_ERROR,
"timerfd_create() not supported by the kernel. Not loading.\n");
static enum ast_timer_event timerfd_timer_get_event(void *data)
Asterisk main include file. File version handling, generic pbx functions.
Time-related functions and macros.
int ast_unregister_timing_interface(void *handle)
Unregister a previously registered timing interface.
static int load_module(void)
static void * timing_funcs_handle
static int timerfd_timer_ack(void *data, unsigned int quantity)
static struct ast_timing_interface timerfd_timing
#define ast_debug(level,...)
Log a DEBUG message.
static int timerfd_timer_disable_continuous(void *data)
unsigned int is_continuous
struct itimerspec saved_timer
#define ao2_ref(o, delta)
static void timerfd_timer_close(void *data)
static int timerfd_timer_enable_continuous(void *data)
static void * timerfd_timer_open(void)
#define ao2_alloc(data_size, destructor_fn)
static unsigned int timerfd_timer_get_max_rate(void *data)
Module has failed to load, may be in an inconsistent state.
static int unload_module(void)
static int timerfd_timer_set_rate(void *data, unsigned int rate)
Support for logging to various files, console and syslog Configuration in file logger.conf.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static void timer_destroy(void *obj)
static int timerfd_timer_fd(void *data)
#define ast_register_timing_interface(i)
Register a set of timing functions.
#define ASTERISK_GPL_KEY
The text the key() function should return.
static struct ast_timer * timer
Asterisk module definitions.
Timing source management.